public class BinomialDist extends DiscreteDistributionInt
DiscreteDistributionInt for the
binomial distribution with parameters n and p, where
n is a positive integer and
0 <= p <= 1.
Its mass function is given by
and its distribution function is
| Modifier and Type | Field and Description |
|---|---|
static double |
MAXN |
EPSILON| Constructor and Description |
|---|
BinomialDist(int n,
double p)
Creates an object that contains the binomial terms, for
0 <= x <= n, and the corresponding
cumulative function.
|
| Modifier and Type | Method and Description |
|---|---|
double |
barF(int x)
Returns bar(F)(x), the complementary
distribution function.
|
double |
cdf(int x)
Returns the distribution function F evaluated at x
(see).
|
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 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 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 x[i],
i = 0, 1,…, m - 1.
|
static double[] |
getMaximumLikelihoodEstimate(int[] x,
int m)
Deprecated.
|
static double[] |
getMaximumLikelihoodEstimate(int[] x,
int m,
int n)
Deprecated.
|
double |
getMean()
Returns the mean of the distribution function.
|
static double |
getMean(int n,
double p)
Computes the mean E[X] = np of the binomial distribution with
parameters n and p.
|
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
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.
|
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].
|
double |
getStandardDeviation()
Returns the standard deviation of the distribution function.
|
static double |
getStandardDeviation(int n,
double p)
Computes the standard deviation of the Binomial distribution with
parameters n and p.
|
double |
getVariance()
Returns the variance of the distribution function.
|
static double |
getVariance(int n,
double p)
Computes the variance
Var[X] = np(1 - p) of the binomial
distribution with parameters n and p.
|
static int |
inverseF(int n,
double p,
double u)
Computes the inverse of the binomial distribution,
x = F-1(u), using a linear search starting at the mode if n is small.
|
int |
inverseFInt(double u)
Returns the inverse distribution function
F-1(u), where
0 <= u <= 1.
|
double |
prob(int x)
Returns p(x), the probability of x,
which should be a real number in the interval [0, 1].
|
static double |
prob(int n,
double p,
double q,
int x)
A generalization of the previous method.
|
static double |
prob(int n,
double p,
int x)
Computes and returns the binomial probability p(x) in eq..
|
void |
setParams(int n,
double p)
Resets the parameters to these new values and recomputes everything
as in the constructor.
|
java.lang.String |
toString() |
public BinomialDist(int n,
double p)
public double prob(int x)
DiscreteDistributionIntprob in class DiscreteDistributionIntx - value at which the mass function must be evaluatedpublic double cdf(int x)
DiscreteDistributionIntcdf in class DiscreteDistributionIntx - value at which the distribution function must be evaluatedpublic double barF(int x)
DiscreteDistributionIntbarF in class DiscreteDistributionIntx - value at which the complementary distribution function
must be evaluatedpublic int inverseFInt(double u)
DiscreteDistributionIntinverseFInt in class DiscreteDistributionIntu - value in the interval (0, 1) for which
the inverse distribution function is evaluatedpublic double getMean()
Distributionpublic double getVariance()
Distributionpublic double getStandardDeviation()
Distributionpublic static double prob(int n,
double p,
int x)
public static double prob(int n,
double p,
double q,
int x)
public static double cdf(int n,
double p,
int x)
public static int inverseF(int n,
double p,
double u)
cdf static method is used to compute F(x) at
different values of x, which much is less efficient.public static double[] getMLE(int[] x,
int m)
x - the list of observations used to evaluate parametersm - the number of observations used to evaluate parameters@Deprecated
public static double[] getMaximumLikelihoodEstimate(int[] x,
int m)
getMLE.public static BinomialDist getInstanceFromMLE(int[] x, int m)
x - the list of observations to use to estimate the parametersm - the number of observations to use to estimate the parameterspublic static double[] getMLE(int[] x,
int m,
int n)
x - the list of observations used to evaluate parametersm - the number of observations used to evaluate parametersn - the number of success@Deprecated
public static double[] getMaximumLikelihoodEstimate(int[] x,
int m,
int n)
getMLE.public static BinomialDist getInstanceFromMLE(int[] x, int m, int n)
x - the list of observations to use to evaluate parametersm - the number of observations to use to evaluate parametersn - the parameter n of the binomialpublic static double getMean(int n,
double p)
public static double getVariance(int n,
double p)
public static double getStandardDeviation(int n,
double p)
public int getN()
public double getP()
public double[] getParams()
public void setParams(int n,
double p)
BinomialDist object.public java.lang.String toString()
toString in class java.lang.ObjectTo submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.