Changeset 3099 in Sophya for trunk/SophyaLib/BaseTools/srandgen.c
- Timestamp:
- Nov 2, 2006, 3:37:05 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/srandgen.c
r3074 r3099 243 243 } 244 244 245 /*! \ingroup BaseTools 246 \brief Poisson random number generator. 247 248 Return an integer value (>=0) corresponding a Poisson distribution with mean \b mu. 249 \warning NOT the most efficient way of generating a large series of numbers 250 with the SAME mean 251 */ 252 int PoissRand(double mu) 253 { 254 double pp,ppi; 255 ppi = pp = exp(-mu); 256 double x = drand01(); 257 int n = 0; 258 while (x > ppi) { 259 n++; 260 pp = mu*pp/(double)n; 261 ppi += pp; 262 } 263 return n; 264 } 265 245 266 /*=========================================================================*/ 246 267 /* … … 250 271 sigma "s" la distribution est limitee entre am +/- GAU_RANGE (obsolete). 251 272 -- 273 */ 274 /*! \ingroup BaseTools 275 \brief OBSOLETE (gaussian random number generator) 252 276 */ 253 277 double GauRnd1(double am, double s) … … 371 395 } 372 396 397 398 /*! 399 \ingroup BaseTools 400 \class SOPHYA::RandomGenerator 401 \brief Random number generator 402 403 This is a class with static methods, providing an alternative interface 404 to random number generations functions declared in srandgen.h. 405 406 \sa frand01 drand01 frandpm1 drandpm1 407 \sa GauRnd PoissRand 408 \sa Ini_Ranf_Quick Ini_Ranf Get_Ranf Auto_Ini_Ranf 409 */ 410 373 411 /*==========================================================================*/ 374 412 /*
Note:
See TracChangeset
for help on using the changeset viewer.