Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

Binomial1 Class Reference

Inheritance diagram for Binomial1:

Inheritance graph
[legend]
Collaboration diagram for Binomial1:

Collaboration graph
[legend]

Public Member Functions

 Binomial1 (int nx, Real px)
Real Density (Real) const
Real Next ()
ExtReal Mean () const
ExtReal Variance () const

Private Attributes

Real p
Real q
Real ln_p
Real ln_q
Real ln_n_fac
int n

Constructor & Destructor Documentation

Binomial1::Binomial1 int  nx,
Real  px
 

Definition at line 427 of file newran.cpp.

References ln_gamma(), ln_n_fac, ln_p, ln_q, n, p, and q.

00428    : AsymGen((nx + 1) * px), p(px), q(1.0 - px), n(nx)
00429       { ln_p = log(p); ln_q = log(q); ln_n_fac = ln_gamma(n+1); }


Member Function Documentation

Real Binomial1::Density Real   )  const [virtual]
 

Reimplemented from Random.

Definition at line 431 of file newran.cpp.

References ln_gamma(), and Real.

00432 {
00433    double ix = floor(x);                         // use integer part
00434    if (ix < 0.0 || ix > n) return 0.0;
00435    double l = ln_n_fac - ln_gamma(ix+1) - ln_gamma(n-ix+1)
00436       + ix * ln_p + (n-ix) * ln_q;
00437    return  (l < -40.0) ? 0.0 : exp(l);
00438 }

ExtReal Binomial1::Mean  )  const [inline, virtual]
 

Reimplemented from AsymGen.

Definition at line 95 of file newran.cpp.

00095 { return p * n; }

Real Binomial1::Next  )  [inline, virtual]
 

Reimplemented from AsymGen.

Definition at line 94 of file newran.cpp.

References AsymGen::Next(), and Real.

00094 { return floor(AsymGen::Next()); }

ExtReal Binomial1::Variance  )  const [inline, virtual]
 

Reimplemented from AsymGen.

Definition at line 96 of file newran.cpp.

00096 { return p * q * n; }


Field Documentation

Real Binomial1::ln_n_fac [private]
 

Definition at line 90 of file newran.cpp.

Referenced by Binomial1().

Real Binomial1::ln_p [private]
 

Definition at line 90 of file newran.cpp.

Referenced by Binomial1().

Real Binomial1::ln_q [private]
 

Definition at line 90 of file newran.cpp.

Referenced by Binomial1().

int Binomial1::n [private]
 

Definition at line 90 of file newran.cpp.

Referenced by Binomial1().

Real Binomial1::p [private]
 

Definition at line 90 of file newran.cpp.

Referenced by Binomial1().

Real Binomial1::q [private]
 

Definition at line 90 of file newran.cpp.

Referenced by Binomial1().


The documentation for this class was generated from the following file:
Generated on Fri Dec 5 04:06:15 2003 for Borqueror by doxygen 1.3.3