#include <newran.h>
Inheritance diagram for AsymGen:


Public Member Functions | |
| char * | Name () |
| AsymGen (Real) | |
| virtual | ~AsymGen () |
| Real | Next () |
| ExtReal | Mean () const |
| ExtReal | Variance () const |
Protected Attributes | |
| Real | mode |
Private Member Functions | |
| void | operator= (const AsymGen &) |
| void | Build () |
Private Attributes | |
| Real | xi |
| Real * | sx |
| Real * | sfx |
| int | ic |
| bool | NotReady |
|
|
Definition at line 261 of file newran.cpp. References mode, NotReady, and tron.
|
|
|
Definition at line 318 of file newran.cpp. References NotReady, sfx, sx, and tron.
|
|
|
Definition at line 269 of file newran.cpp. References Random::Density(), ErrorNoSpace(), ic, mode, NotReady, Real, sfx, sx, tron, and xi. Referenced by Next().
00270 {
00271 #ifdef MONITOR
00272 tron << "building AsymGen arrays\n";
00273 #endif
00274 int i;
00275 NotReady=false;
00276 sx=new Real[121]; sfx=new Real[121];
00277 if (!sx || !sfx) ErrorNoSpace();
00278 Real sxi=mode;
00279 for (i=0; i<120; i++)
00280 {
00281 sx[i]=sxi; Real f1=Density(sxi); sfx[i]=f1;
00282 if (f1<=0.0) goto L20;
00283 sxi+=0.01/f1;
00284 }
00285 Throw(Runtime_error("Newran: area too large (a)"));
00286 L20:
00287 ic=i-1; sx[120]=sxi; sfx[120]=0.0;
00288 sxi=mode;
00289 for (; i<120; i++)
00290 {
00291 sx[i]=sxi; Real f1=Density(sxi); sfx[i]=f1;
00292 if (f1<=0.0) goto L30;
00293 sxi-=0.01/f1;
00294 }
00295 Throw(Runtime_error("Newran: area too large (b)"));
00296 L30:
00297 if (i<100) Throw(Runtime_error("Newran: area too small"));
00298 xi=i;
00299 return;
00300 }
|
|
|
Reimplemented from Random. Reimplemented in Poisson1, Gamma2, Binomial1, and NegativeBinomial. Definition at line 203 of file newran.h. References Missing.
|
|
|
Reimplemented from Random. Reimplemented in AsymGenX, and NegativeBinomial. Definition at line 907 of file newran.cpp.
00907 { return "AsymGen"; }
|
|
|
Reimplemented from Random. Reimplemented in Poisson1, Binomial1, and NegativeBinomial. Definition at line 302 of file newran.cpp. References Build(), Random::Density(), ic, Random::Next(), NotReady, Real, sfx, sx, and xi. Referenced by NegativeBinomial::Next(), Binomial1::Next(), and Poisson1::Next().
00303 {
00304 Real ak,y; int ir1;
00305 if (NotReady) Build();
00306 do
00307 {
00308 Real r1=Random::Next();
00309 int ir=(int)(r1*xi); Real sxi=sx[ir];
00310 ir1 = (ir==ic) ? 120 : ir+1;
00311 ak=sxi+(sx[ir1]-sxi)*Random::Next();
00312 y=sfx[ir]*Random::Next();
00313 }
00314 while ( y>=sfx[ir1] && y>=Density(ak) );
00315 return ak;
00316 }
|
|
|
Definition at line 190 of file newran.h.
00190 {} // private so can't access
|
|
|
Reimplemented from Random. Reimplemented in Poisson1, Gamma2, Binomial1, and NegativeBinomial. Definition at line 204 of file newran.h. References Missing.
|
|
|
|
|
|
Definition at line 196 of file newran.h. Referenced by AsymGen(), Build(), and NegativeBinomial::NegativeBinomial(). |
|
|
Definition at line 192 of file newran.h. Referenced by AsymGen(), Build(), Next(), and ~AsymGen(). |
|
|
Definition at line 191 of file newran.h. Referenced by Build(), Next(), and ~AsymGen(). |
|
|
Definition at line 191 of file newran.h. Referenced by Build(), Next(), and ~AsymGen(). |
|
|
|
1.3.3