public class NegativeBinomialDist extends DiscreteDistributionInt
DiscreteDistributionInt for
the negative binomial distribution with real
parameters γ and p, where
γ > 0 and
0 <= p <= 1.
Its mass function is
where Γ is the gamma function.
If γ is an integer, p(x) can be interpreted as the probability
of having x failures before the γ-th success in a sequence of
independent Bernoulli trials with probability of success p. This special
case is implemented as the Pascal distribution (see PascalDist).
| Modifier and Type | Field and Description |
|---|---|
static double |
MAXN |
EPSILON| Constructor and Description |
|---|
NegativeBinomialDist(double gamma,
double p)
Creates an object that contains the probability
terms and the distribution function for
the negative binomial distribution with parameters γ and p.
|
| Modifier and Type | Method and Description |
|---|---|
double |
barF(int x)
Returns bar(F)(x), the complementary
distribution function.
|
static double |
cdf(double gamma,
double p,
int x)
Computes the distribution function.
|
double |
cdf(int x)
Returns the distribution function F evaluated at x
(see).
|
double |
getGamma()
Returns the parameter γ of this object.
|
static NegativeBinomialDist |
getInstanceFromMLE(int[] x,
int n)
Creates a new instance of a negative binomial distribution with
parameters γ and p estimated using the maximum likelihood method
based on the n observations x[i],
i = 0, 1,…, n - 1.
|
static NegativeBinomialDist |
getInstanceFromMLE(int[] x,
int n,
double gamma)
Creates a new instance of a negative binomial distribution with parameters
γ = gamma given and hat(p) estimated using the maximum
likelihood method, from the n observations x[i],
i = 0, 1,…, n - 1.
|
static double[] |
getMaximumLikelihoodEstimate(int[] x,
int n)
Deprecated.
|
static double[] |
getMaximumLikelihoodEstimate(int[] x,
int n,
double gamma)
Deprecated.
|
double |
getMean()
Returns the mean of the distribution function.
|
static double |
getMean(double gamma,
double p)
Computes and returns the mean
E[X] = γ(1 - p)/p
of the negative binomial distribution with parameters γ and p.
|
static double[] |
getMLE(int[] x,
int n)
Estimates the parameter
(γ, p) of the negative binomial distribution
using the maximum likelihood method, from the n observations
x[i],
i = 0, 1,…, n - 1.
|
static double[] |
getMLE(int[] x,
int n,
double gamma)
Estimates the parameter p of the negative binomial distribution
using the maximum likelihood method, from the n observations
x[i],
i = 0, 1,…, n - 1.
|
double |
getP()
Returns the parameter p of this object.
|
double[] |
getParams()
Return a table containing the parameters of the current distribution.
|
double |
getStandardDeviation()
Returns the standard deviation of the distribution function.
|
static double |
getStandardDeviation(double gamma,
double p)
Computes and returns the standard deviation of the negative
binomial distribution with parameters γ and p.
|
double |
getVariance()
Returns the variance of the distribution function.
|
static double |
getVariance(double gamma,
double p)
Computes and returns the variance
Var[X] = γ(1 - p)/p2
of the negative binomial distribution with parameters γ and p.
|
static int |
inverseF(double gamma,
double p,
double u)
Computes the inverse function without precomputing tables.
|
int |
inverseFInt(double u)
Returns the inverse distribution function
F-1(u), where
0 <= u <= 1.
|
static double |
prob(double gamma,
double p,
int x)
Computes the probability p(x).
|
double |
prob(int x)
Returns p(x), the probability of x,
which should be a real number in the interval [0, 1].
|
void |
setParams(double gamma,
double p)
Sets the parameter γ and p of this object.
|
java.lang.String |
toString() |
public NegativeBinomialDist(double gamma,
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(double gamma,
double p,
int x)
public static double cdf(double gamma,
double p,
int x)
public static int inverseF(double gamma,
double p,
double u)
public static double[] getMLE(int[] x,
int n,
double gamma)
x - the list of observations used to evaluate parametersn - the number of observations used to evaluate parametersgamma - the first parameter of the negative binomial@Deprecated
public static double[] getMaximumLikelihoodEstimate(int[] x,
int n,
double gamma)
getMLE.public static NegativeBinomialDist getInstanceFromMLE(int[] x, int n, double gamma)
x - the list of observations to use to evaluate parametersn - the number of observations to use to evaluate parametersgamma - the first parameter of the negative binomialpublic static double[] getMLE(int[] x,
int n)
x - the list of observations used to evaluate parametersn - the number of observations used to evaluate parameters@Deprecated
public static double[] getMaximumLikelihoodEstimate(int[] x,
int n)
getMLE.public static NegativeBinomialDist getInstanceFromMLE(int[] x, int n)
x - the list of observations to use to evaluate parametersn - the number of observations to use to evaluate parameterspublic static double getMean(double gamma,
double p)
public static double getVariance(double gamma,
double p)
public static double getStandardDeviation(double gamma,
double p)
public double getGamma()
public double getP()
public void setParams(double gamma,
double p)
public double[] getParams()
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.