Extends the class DiscreteDistributionInt for the binomial distribution [114] (page 321) with parameters \(n\) and. More...
Public Member Functions | |
| BinomialDist (int n, double p) | |
Creates an object that contains the binomial terms ( fmass-binomial ), for \(0\le x\le n\), and the corresponding cumulative function. | |
| double | prob (int x) |
| Returns \(p(x)\), the probability of \(x\). | |
| double | cdf (int x) |
Returns the distribution function \(F\) evaluated at \(x\) (see ( FDistDisc )). | |
| double | barF (int x) |
| Returns \(\bar{F}(x)\), the complementary distribution function. | |
| int | inverseFInt (double u) |
| Returns the inverse distribution function \(F^{-1}(u)\), where. | |
| double | getMean () |
| Returns the mean of the distribution function. | |
| double | getVariance () |
| Returns the variance of the distribution function. | |
| double | getStandardDeviation () |
| Returns the standard deviation of the distribution function. | |
| int | getN () |
| Returns the parameter \(n\) of this object. | |
| double | getP () |
| Returns the parameter \(p\) of this object. | |
| double[] | getParams () |
| Returns a table that contains the parameters \((n,p)\) of the current distribution, in regular order: [ \(n\), \(p\)]. | |
| void | setParams (int n, double p) |
| Resets the parameters to these new values and recomputes everything as in the constructor. | |
| String | toString () |
| Returns a String containing information about the current distribution. | |
| Public Member Functions inherited from umontreal.ssj.probdist.DiscreteDistributionInt | |
| double | cdf (double x) |
Returns the distribution function \(F\) evaluated at \(x\) (see ( FDistDisc )). | |
| double | barF (double x) |
| Returns \(\bar{F}(x)\), the complementary distribution function. | |
| int | getXinf () |
| Returns the lower limit \(x_a\) of the support of the probability mass function. | |
| int | getXsup () |
| Returns the upper limit \(x_b\) of the support of the probability mass function. | |
| double | inverseF (double u) |
| Returns the inverse distribution function \(F^{-1}(u)\), where. | |
Static Public Member Functions | |
| static double | prob (int n, double p, int x) |
| Computes and returns the binomial probability \(p(x)\) in eq. | |
| static double | prob (int n, double p, double q, int x) |
| A generalization of the previous method. | |
| static double | cdf (int n, double p, int x) |
| Computes \(F(x)\), the distribution function of a binomial random variable with parameters \(n\) and \(p\), evaluated at \(x\). | |
| static double | barF (int n, double p, int x) |
| Returns \(\bar{F}(x) = P[X \ge x]\), the complementary distribution function. | |
| static int | inverseF (int n, double p, double u) |
| Computes \(x = F^{-1}(u)\), the inverse of the binomial distribution. | |
| static double[] | getMLE (int[] x, int m) |
| Estimates the parameters \((n,p)\) of the binomial distribution using the maximum likelihood method, from the \(m\) observations. | |
| static BinomialDist | getInstanceFromMLE (int[] x, int m) |
| Creates a new instance of a binomial distribution with both parameters \(n\) and \(p\) estimated using the maximum likelihood method, from the \(m\) observations \(x[i]\), \(i = 0, 1, …, m-1\). | |
| static double[] | getMLE (int[] x, int m, int n) |
| Estimates the parameter \(p\) of the binomial distribution with given (fixed) parameter \(n\), by the maximum likelihood method, from the \(m\) observations \(x[i]\), \(i = 0, 1,…, m-1\). | |
| static BinomialDist | getInstanceFromMLE (int[] x, int m, int n) |
| Creates a new instance of a binomial distribution with given (fixed) parameter \(n\), and with parameter \(p\) estimated by the maximum likelihood method based on the \(m\) observations. | |
| static double | getMean (int n, double p) |
| Computes the mean \(E[X] = np\) of the binomial distribution with parameters \(n\) and \(p\). | |
| static double | getVariance (int n, double p) |
| Computes the variance \(\mbox{Var}[X] = np(1 - p)\) of the binomial distribution with parameters \(n\) and \(p\). | |
| static double | getStandardDeviation (int n, double p) |
| Computes the standard deviation of the Binomial distribution with parameters \(n\) and \(p\). | |
Static Public Attributes | |
Constant @{ | |
| static double | MAXN = 100000 |
| The value of the parameter \(n\) above which the tables are not precomputed by the constructor. | |
| Static Public Attributes inherited from umontreal.ssj.probdist.DiscreteDistributionInt | |
| static double | EPSILON = 1.0e-16 |
| Environment variable that determines what probability terms can be considered as negligible when building precomputed tables for distribution and mass functions. | |
Extends the class DiscreteDistributionInt for the binomial distribution [114] (page 321) with parameters \(n\) and.
\(p\), where \(n\) is a positive integer and \(0\le p\le1\). Its mass function is given by
\[ p(x) = \binom{n}{x} p^x (1-p)^{n-x} = \frac{n!}{x!(n-x)!}\; p^x (1-p)^{n-x} \qquad\mbox{for } x = 0, 1, 2,…n, \tag{fmass-binomial} \]
and its distribution function is
\[ F (x) = \sum_{j=0}^x \binom{n}{j}\; p^j (1-p)^{n-j} \qquad\mbox{for } x = 0, 1, 2, …n, \tag{Fbinomial} \]
where nCr \((n,x)\) is the number of possible combinations of \(x\) elements chosen among a set of \(n\) elements.
Definition at line 50 of file BinomialDist.java.
| umontreal.ssj.probdist.BinomialDist.BinomialDist | ( | int | n, |
| double | p ) |
Creates an object that contains the binomial terms ( fmass-binomial ), for \(0\le x\le n\), and the corresponding cumulative function.
These values are computed and stored in dynamic arrays, unless \(n\) exceeds MAXN.
Definition at line 103 of file BinomialDist.java.
|
static |
Returns \(\bar{F}(x) = P[X \ge x]\), the complementary distribution function.
The default implementation returns 1 - cdf(x-1), which is not accurate when \(F(x)\) is close to 1.
Definition at line 430 of file BinomialDist.java.
| double umontreal.ssj.probdist.BinomialDist.barF | ( | int | x | ) |
Returns \(\bar{F}(x)\), the complementary distribution function.
See the WARNING above. The default implementation returns 1.0 - cdf(x - 1), which is not accurate when \(F(x)\) is near 1.
| x | value at which the complementary distribution function must be evaluated |
Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.
Definition at line 179 of file BinomialDist.java.
|
static |
Computes \(F(x)\), the distribution function of a binomial random variable with parameters \(n\) and \(p\), evaluated at \(x\).
If \(n \le10000\), the non-negligible terms of the sum are added explicitly. If \(n > 10000\) and \(np (1-p) > 100\), the Camp-Paulson normal approximation [30],
[176] is used, otherwise, a Poisson approximation due to Bol’shev [21], [176] is used.
Definition at line 330 of file BinomialDist.java.
| double umontreal.ssj.probdist.BinomialDist.cdf | ( | int | x | ) |
Returns the distribution function \(F\) evaluated at \(x\) (see ( FDistDisc )).
| x | value at which the distribution function must be evaluated |
Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.
Definition at line 137 of file BinomialDist.java.
|
static |
Creates a new instance of a binomial distribution with both parameters \(n\) and \(p\) estimated using the maximum likelihood method, from the \(m\) observations \(x[i]\), \(i = 0, 1, …, m-1\).
| x | the list of observations to use to estimate the parameters |
| m | the number of observations to use to estimate the parameters |
Definition at line 587 of file BinomialDist.java.
|
static |
Creates a new instance of a binomial distribution with given (fixed) parameter \(n\), and with parameter \(p\) estimated by the maximum likelihood method based on the \(m\) observations.
\(x[i]\), \(i = 0, 1, …, m-1\).
| x | the list of observations to use to evaluate parameters |
| m | the number of observations to use to evaluate parameters |
| n | the parameter n of the binomial |
Definition at line 630 of file BinomialDist.java.
| double umontreal.ssj.probdist.BinomialDist.getMean | ( | ) |
Returns the mean of the distribution function.
Implements umontreal.ssj.probdist.Distribution.
Definition at line 232 of file BinomialDist.java.
|
static |
Computes the mean \(E[X] = np\) of the binomial distribution with parameters \(n\) and \(p\).
Definition at line 642 of file BinomialDist.java.
|
static |
Estimates the parameters \((n,p)\) of the binomial distribution using the maximum likelihood method, from the \(m\) observations.
\(x[i]\), \(i = 0, 1,…, m-1\). The estimates are returned in a two-element array, in regular order: [ \(n\), \(p\)]. The maximum likelihood estimators are the values \((\hat{n}, \hat{p})\) that satisfy the equations:
\begin{align*} \hat{n}\hat{p} & = \bar{x}_m \\ \sum_{i=0}^{R-1} \frac{f_i}{\hat{n} - i} & = - m \ln\left(1 - \frac{\bar{x}_m}{\hat{n}}\right) \end{align*}
where \(\bar{x}_m\) is the average of \(x[0],…,x[m-1]\), \(f_i\) is the number of \(x[i]\)’s that exceed \(i\), and \(R =\max(x[0],…,x[m-1])\) is the largest observation [93] (page 57).
| x | the list of observations used to evaluate parameters |
| m | the number of observations used to evaluate parameters |
Definition at line 535 of file BinomialDist.java.
|
static |
Estimates the parameter \(p\) of the binomial distribution with given (fixed) parameter \(n\), by the maximum likelihood method, from the \(m\) observations \(x[i]\), \(i = 0, 1,…, m-1\).
Returns the estimator in an array with a single element.
| x | the list of observations used to evaluate parameters |
| m | the number of observations used to evaluate parameters |
| n | the number of success |
Definition at line 604 of file BinomialDist.java.
| int umontreal.ssj.probdist.BinomialDist.getN | ( | ) |
Returns the parameter \(n\) of this object.
Definition at line 789 of file BinomialDist.java.
| double umontreal.ssj.probdist.BinomialDist.getP | ( | ) |
Returns the parameter \(p\) of this object.
Definition at line 796 of file BinomialDist.java.
| double[] umontreal.ssj.probdist.BinomialDist.getParams | ( | ) |
Returns a table that contains the parameters \((n,p)\) of the current distribution, in regular order: [ \(n\), \(p\)].
Implements umontreal.ssj.probdist.Distribution.
Definition at line 804 of file BinomialDist.java.
| double umontreal.ssj.probdist.BinomialDist.getStandardDeviation | ( | ) |
Returns the standard deviation of the distribution function.
Implements umontreal.ssj.probdist.Distribution.
Definition at line 240 of file BinomialDist.java.
|
static |
Computes the standard deviation of the Binomial distribution with parameters \(n\) and \(p\).
Definition at line 673 of file BinomialDist.java.
| double umontreal.ssj.probdist.BinomialDist.getVariance | ( | ) |
Returns the variance of the distribution function.
Implements umontreal.ssj.probdist.Distribution.
Definition at line 236 of file BinomialDist.java.
|
static |
Computes the variance \(\mbox{Var}[X] = np(1 - p)\) of the binomial distribution with parameters \(n\) and \(p\).
Definition at line 658 of file BinomialDist.java.
|
static |
Computes \(x = F^{-1}(u)\), the inverse of the binomial distribution.
If \(n\) is larger than 10000, the linear search starts from 0 and the cdf(int,double,int) static method is used to compute \(F(x)\) at different values of \(x\), which is much less efficient.
Definition at line 440 of file BinomialDist.java.
| int umontreal.ssj.probdist.BinomialDist.inverseFInt | ( | double | u | ) |
Returns the inverse distribution function \(F^{-1}(u)\), where.
\(0\le u\le1\). The default implementation uses binary search.
| u | value in the interval \((0,1)\) for which the inverse distribution function is evaluated |
| IllegalArgumentException | if \(u\) is not in the interval \((0,1)\) |
| ArithmeticException | if the inverse cannot be computed, for example if it would give infinity in a theoritical context |
Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.
Definition at line 225 of file BinomialDist.java.
|
static |
A generalization of the previous method.
Computes and returns the binomial term
\[ f(x) = \binom{n}{x} p^x q^{n-x} = \frac{n!}{x!(n-x)!}\; p^x q^{n-x}, \tag{fmass-binom} \]
where \(p\) and \(q\) are arbitrary real numbers ( \(q\) is not necessarily equal to \(1-p\)). In the case where \(0 \le p \le1\) and \(q = 1-p\), the returned value is a probability term for the binomial distribution.
Definition at line 263 of file BinomialDist.java.
|
static |
Computes and returns the binomial probability \(p(x)\) in eq.
( fmass-binomial ).
Definition at line 248 of file BinomialDist.java.
| double umontreal.ssj.probdist.BinomialDist.prob | ( | int | x | ) |
Returns \(p(x)\), the probability of \(x\).
| x | value at which the mass function must be evaluated |
Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.
Definition at line 107 of file BinomialDist.java.
| void umontreal.ssj.probdist.BinomialDist.setParams | ( | int | n, |
| double | p ) |
Resets the parameters to these new values and recomputes everything as in the constructor.
From the performance viewpoint, it is essentially the same as constructing a new BinomialDist object.
Definition at line 814 of file BinomialDist.java.
| String umontreal.ssj.probdist.BinomialDist.toString | ( | ) |
Returns a String containing information about the current distribution.
Definition at line 821 of file BinomialDist.java.
|
static |
The value of the parameter \(n\) above which the tables are not precomputed by the constructor.
Definition at line 90 of file BinomialDist.java.