#include <Binomial.h>
Public Member Functions | |
Binomial () | |
Binomial (long n, double p) | |
long | getN () const |
double | getP () const |
double | getMean () const |
double | getVariance () const |
double | getNextSample () const |
Binomial::Binomial | ( | ) | [inline] |
Binomial::Binomial | ( | long | n, | |
double | p | |||
) |
Binomial distribution generator with parameters n and p. p is the probability of the favoured outcome, n is the number of trials.
double Binomial::getMean | ( | ) | const [virtual] |
Implements Probability.
Referenced by testBinomial().
long Binomial::getN | ( | ) | const |
double Binomial::getNextSample | ( | ) | const [virtual] |
returns the next random number in this distribution as the ratio of the number of positive outcomes and the total number of trials. This is the most naive implementation. This is ok for small n. For large n such that mean > 10, we use BTRD algorithm by Hoermann. See documentation of generateTrd() for further detail.
Implements Probability.
References mtrand().
Referenced by testBinomial().
double Binomial::getP | ( | ) | const |
double Binomial::getVariance | ( | ) | const [virtual] |
Implements Probability.