umontreal.iro.lecuyer.probdist
Class NegativeBinomialDist
- java.lang.Object
-
- umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
-
- umontreal.iro.lecuyer.probdist.NegativeBinomialDist
-
- All Implemented Interfaces:
- Distribution
- Direct Known Subclasses:
- PascalDist
public class NegativeBinomialDist extends DiscreteDistributionInt
Extends the classDiscreteDistributionIntfor 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).
-
-
Field Summary
Fields Modifier and Type Field and Description static doubleMAXN-
Fields inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
EPSILON
-
-
Constructor Summary
Constructors 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublebarF(int x)Returns bar(F)(x), the complementary distribution function.static doublecdf(double gamma, double p, int x)Computes the distribution function.doublecdf(int x)Returns the distribution function F evaluated at x (see).doublegetGamma()Returns the parameter γ of this object.static NegativeBinomialDistgetInstanceFromMLE(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 NegativeBinomialDistgetInstanceFromMLE(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 NegativeBinomialDistgetInstanceFromMLE1(int[] x, int n, double p)Creates a new instance of a negative binomial distribution with parameters p given and hat(γ) estimated using the maximum likelihood method, from the n observations x[i], i = 0, 1,…, n - 1.doublegetMean()Returns the mean of the distribution function.static doublegetMean(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.static double[]getMLE1(int[] x, int n, double p)Estimates the parameter γ of the negative binomial distribution using the maximum likelihood method, from the n observations x[i], i = 0, 1,…, n - 1.doublegetP()Returns the parameter p of this object.double[]getParams()Return a table containing the parameters of the current distribution.doublegetStandardDeviation()Returns the standard deviation of the distribution function.static doublegetStandardDeviation(double gamma, double p)Computes and returns the standard deviation of the negative binomial distribution with parameters γ and p.doublegetVariance()Returns the variance of the distribution function.static doublegetVariance(double gamma, double p)Computes and returns the variance Var[X] = γ(1 - p)/p2 of the negative binomial distribution with parameters γ and p.static intinverseF(double gamma, double p, double u)Computes the inverse function without precomputing tables.intinverseFInt(double u)Returns the inverse distribution function F-1(u), where 0 <= u <= 1.static doubleprob(double gamma, double p, int x)Computes the probability p(x).doubleprob(int x)Returns p(x), the probability of x, which should be a real number in the interval [0, 1].voidsetParams(double gamma, double p)Sets the parameter γ and p of this object.java.lang.StringtoString()
-
-
-
Constructor Detail
-
NegativeBinomialDist
public 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.
-
-
Method Detail
-
prob
public double prob(int x)
Description copied from class:DiscreteDistributionIntReturns p(x), the probability of x, which should be a real number in the interval [0, 1].- Specified by:
probin classDiscreteDistributionInt- Parameters:
x- value at which the mass function must be evaluated- Returns:
- the mass function evaluated at x
-
cdf
public double cdf(int x)
Description copied from class:DiscreteDistributionIntReturns the distribution function F evaluated at x (see).- Specified by:
cdfin classDiscreteDistributionInt- Parameters:
x- value at which the distribution function must be evaluated- Returns:
- the distribution function evaluated at x
-
barF
public double barF(int x)
Description copied from class:DiscreteDistributionIntReturns bar(F)(x), the complementary distribution function. See the WARNING above.- Overrides:
barFin classDiscreteDistributionInt- Parameters:
x- value at which the complementary distribution function must be evaluated- Returns:
- the complementary distribution function evaluated at x
-
inverseFInt
public int inverseFInt(double u)
Description copied from class:DiscreteDistributionIntReturns the inverse distribution function F-1(u), where 0 <= u <= 1. The default implementation uses binary search.- Overrides:
inverseFIntin classDiscreteDistributionInt- Parameters:
u- value in the interval (0, 1) for which the inverse distribution function is evaluated- Returns:
- the inverse distribution function evaluated at u
-
getMean
public double getMean()
Description copied from interface:DistributionReturns the mean of the distribution function.
-
getVariance
public double getVariance()
Description copied from interface:DistributionReturns the variance of the distribution function.
-
getStandardDeviation
public double getStandardDeviation()
Description copied from interface:DistributionReturns the standard deviation of the distribution function.
-
prob
public static double prob(double gamma, double p, int x)Computes the probability p(x).
-
cdf
public static double cdf(double gamma, double p, int x)Computes the distribution function.
-
inverseF
public static int inverseF(double gamma, double p, double u)Computes the inverse function without precomputing tables. This method computes the CDF at the mode (maximum term) and performs a linear search from that point.
-
getMLE
public 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. The parameter γ = gamma is assumed known. The estimate hat(p) is returned in element 0 of the returned array. The maximum likelihood estimator hat(p) satisfies the equation hat(p) = γ/(γ + bar(x)n), where bar(x)n is the average of x[0],…, x[n - 1].- Parameters:
x- the list of observations used to evaluate parametersn- the number of observations used to evaluate parametersgamma- the first parameter of the negative binomial- Returns:
- returns the parameters [hat(p)]
-
getInstanceFromMLE
public 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.- Parameters:
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 binomial
-
getMLE1
public static double[] getMLE1(int[] x, int n, double p)Estimates the parameter γ of the negative binomial distribution using the maximum likelihood method, from the n observations x[i], i = 0, 1,…, n - 1. The parameter p is assumed known. The estimate hat(γ) is returned in element 0 of the returned array.- Parameters:
x- the list of observations used to evaluate parametersn- the number of observations used to evaluate parametersp- the second parameter of the negative binomial- Returns:
- returns the parameters [ hat(γ)]
-
getInstanceFromMLE1
public static NegativeBinomialDist getInstanceFromMLE1(int[] x, int n, double p)
Creates a new instance of a negative binomial distribution with parameters p given and hat(γ) estimated using the maximum likelihood method, from the n observations x[i], i = 0, 1,…, n - 1.- Parameters:
x- the list of observations to use to evaluate parametersn- the number of observations to use to evaluate parametersp- the second parameter of the negative binomial
-
getMLE
public 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. The estimates are returned in a two-element array, in regular order: [γ, p].- Parameters:
x- the list of observations used to evaluate parametersn- the number of observations used to evaluate parameters- Returns:
- returns the parameters [ hat(γ), hat(p)]
-
getInstanceFromMLE
public 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.- Parameters:
x- the list of observations to use to evaluate parametersn- the number of observations to use to evaluate parameters
-
getMean
public 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.- Returns:
- the mean of the negative binomial distribution E[X] = γ(1 - p)/p
-
getVariance
public 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.- Returns:
- the variance of the negative binomial distribution Var[X] = γ(1 - p)/p2
-
getStandardDeviation
public static double getStandardDeviation(double gamma, double p)Computes and returns the standard deviation of the negative binomial distribution with parameters γ and p.- Returns:
- the standard deviation of the negative binomial distribution
-
getGamma
public double getGamma()
Returns the parameter γ of this object.
-
getP
public double getP()
Returns the parameter p of this object.
-
setParams
public void setParams(double gamma, double p)Sets the parameter γ and p of this object.
-
getParams
public double[] getParams()
Return a table containing the parameters of the current distribution. This table is put in regular order: [γ, p].
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG