

Public Member Functions | |
| Binomial2 (int nx, Real px) | |
| ~Binomial2 () | |
| Real | Next () |
| ExtReal | Mean () const |
| ExtReal | Variance () const |
Private Attributes | |
| DiscreteGen * | dg |
|
||||||||||||
|
Definition at line 451 of file newran.cpp. References dg, ErrorNoSpace(), ln_gamma(), and Real.
00452 {
00453 Real qx = 1.0 - px;
00454 Real probs[40];
00455 int k = (int)(nx * px);
00456 probs[k] = exp(ln_gamma(nx+1) - ln_gamma(k+1) - ln_gamma(nx-k+1)
00457 + k * log(px) + (nx-k) * log(qx));
00458 int i;
00459 int m = (nx >= 40) ? 39 : nx;
00460 for (i=k+1; i<=m; i++) probs[i]=probs[i-1] * px * (nx-i+1) / qx / i;
00461 for (i=k-1; i>=0; i--) probs[i]=probs[i+1] * qx * (i+1) / px / (nx-i);
00462 dg = new DiscreteGen(m + 1, probs);
00463 if (!dg) ErrorNoSpace();
00464 }
|
|
|
Definition at line 466 of file newran.cpp. References dg.
00466 { delete dg; }
|
|
|
Reimplemented from Random. Definition at line 108 of file newran.cpp.
|
|
|
Reimplemented from Random. Definition at line 107 of file newran.cpp. References Real.
|
|
|
Reimplemented from Random. Definition at line 109 of file newran.cpp.
|
|
|
Definition at line 103 of file newran.cpp. Referenced by Binomial2(), and ~Binomial2(). |
1.3.3