|
Honeycomb
0.1
Component-Model Framework
|
Generate a random integer variate from a negative binomial distribution. More...
#include <BinomialNeg.h>


Public Member Functions | |
| BinomialNeg_ (RandomGen &gen, Real n, Real p) | |
| virtual Real | next () const |
| Get next randomly distributed variate. Requires a random generator (see ctor or setGen()) More... | |
| virtual Real | pdf (Real x) const |
| Probability Density Function. More... | |
| virtual Real | cdf (Real x) const |
| Cumulative Distribution Function. More... | |
| virtual Real | cdfInv (Real P) const |
| Inverse of the CDF. More... | |
| virtual Real | mean () const |
| Calc mean. More... | |
| virtual Real | variance () const |
| Calc variance. More... | |
Public Member Functions inherited from honey::RandomDist< Real > | |
| RandomDist (optional< RandomGen & > gen=optnull) | |
| Construct with a random generator to use for next() More... | |
| virtual | ~RandomDist () |
| virtual Real | cdfComp (Real x) const |
| Complement of the CDF. More... | |
| Real | stdDev () const |
| Calc standard deviation. More... | |
| void | setGen (RandomGen &gen) |
| Set random generator to use for next() More... | |
| RandomGen & | getGen () const |
| Get random generator. More... | |
Static Public Member Functions | |
| static Real | trialProb (Int x, Real n, Real P) |
| Calculate trial probability given all other values. More... | |
Public Attributes | |
| Real | n |
| Real | p |
Friends | |
| template<class > | |
| class | BinomialNeg_ |
Additional Inherited Members | |
Protected Types inherited from honey::RandomDist< Real > | |
| typedef Numeral< Real >::Real_ | Real_ |
| typedef Real_::DoubleType | Double_ |
| typedef Double_::Real | Double |
| typedef Alge_< Real > | Alge |
| typedef Alge_< Double > | Alge_d |
| typedef Uniform_< Double > | Uniform |
Protected Member Functions inherited from honey::RandomDist< Real > | |
| Real | cdfInvFind (Real P, Real min, Real max, bool discrete=false) const |
| Generic binary search algorithm to find Cdf. More... | |
Generate a random integer variate from a negative binomial distribution.
The result x is the integer number of failures occurring in a sequence of trials before n successes, where each trial has success probability p.
Example: Toss a coin (head p = 0.5) and count number of tails (x) until the 10th time a head appears (n)
Probability density function:
where
is the gamma function.
| n | Number of successes until the trials are stopped. n is Real so success count can be partial. Range > 0 |
| p | Success probability. Range [0,1] |
| x | Number of failures. Range [0,inf] |
|
inline |
|
virtual |
Cumulative Distribution Function.
The integral of the PDF from -inf to x.
| x | value, range depends on distribution. |
| P | a probability in range [0,1] that a random variate will be <= x. |
Reimplemented from honey::RandomDist< Real >.
|
virtual |
Inverse of the CDF.
| P | cumulative probability |
| x | A value that has probability P of being >= a random variate X. Also, x satisfies: cdf(x) = P. |
Reimplemented from honey::RandomDist< Real >.
|
inlinevirtual |
Calc mean.
Reimplemented from honey::RandomDist< Real >.
|
virtual |
Get next randomly distributed variate. Requires a random generator (see ctor or setGen())
Reimplemented from honey::RandomDist< Real >.
|
virtual |
Probability Density Function.
The PDF integrates to 1 over the entire range of possible values of x.
| x | value, range depends on distribution. |
| p | a relative likelihood in range [0,inf] that a random variate X will equal x. |
Reimplemented from honey::RandomDist< Real >.
|
static |
Calculate trial probability given all other values.
Finds the per trial success probability p such that x or fewer number of failures will occur before n successes, with a probability of P
|
inlinevirtual |
Calc variance.
Reimplemented from honey::RandomDist< Real >.
| Real honey::BinomialNeg_< Real >::n |
| Real honey::BinomialNeg_< Real >::p |
1.8.10