Package com.imsl.stat.distributions
Class NegativeBinomialPD
java.lang.Object
com.imsl.stat.distributions.ProbabilityDistribution
com.imsl.stat.distributions.NegativeBinomialPD
- All Implemented Interfaces:
ClosedFormMaximumLikelihoodInterface,PDFGradientInterface,PDFHessianInterface,Serializable,Cloneable
public class NegativeBinomialPD
extends ProbabilityDistribution
implements Serializable, Cloneable, PDFHessianInterface, ClosedFormMaximumLikelihoodInterface
The negative binomial probability distribution.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[]getClosedFormMLE(double[] x) Returns the closed form maximum likelihood estimate.double[]getClosedFormMlStandardError(double[] x) Returns the standard error based on the closed form maximum likelihood estimate.intReturns the number of successes.double[]Returns the lower bound of the parameter.double[]Returns the upper bound of the parameter.double[]getPDFGradient(double x, double... params) Returns the analytic gradient of the pdf.double[][]getPDFHessian(double x, double... params) Returns the analytic Hessian matrix of the pdf.doublepdf(double x, double... params) Returns the value of the negative binomial probability density function.voidsetNumberOfSuccesses(int numSuccesses) Sets the number of successes.Methods inherited from class com.imsl.stat.distributions.ProbabilityDistribution
getNumberOfParameters, getPDFGradientApproximation, getPDFHessianApproximation, getRangeOfX, setRangeOfX
-
Constructor Details
-
NegativeBinomialPD
public NegativeBinomialPD()Constructor for the binomial probability distribution.
-
-
Method Details
-
getParameterLowerBounds
public double[] getParameterLowerBounds()Returns the lower bound of the parameter.- Specified by:
getParameterLowerBoundsin classProbabilityDistribution- Returns:
- a
doublearray of length 1 containing the lower bound for \(p\)
-
getParameterUpperBounds
public double[] getParameterUpperBounds()Returns the upper bound of the parameter.- Specified by:
getParameterUpperBoundsin classProbabilityDistribution- Returns:
- a
doublearray of length 1 containing the upper bound for \(p\)
-
pdf
public double pdf(double x, double... params) Returns the value of the negative binomial probability density function.The probability density function of the negative binomial distribution is
$$\Pr \left( {X = k} \right) = {k+r-1 \choose r - 1} p^r (1-p)^k, \quad r =1, 2, \ldots, \; k = 0, 1,2, \ldots $$
where \(k\) is the number of failures before obtaining \(r\) successes, and \(p \in [0,1]\) is the success probability in each independent trial.- Specified by:
pdfin classProbabilityDistribution- Parameters:
x- adouble, the number of failures before obtainingrsuccesses.xmust be a non-negative integer. Ifxis not an integer, then it is cast to an integer. The number of successes can be set via methodsetNumberOfSuccesses(int).params- adoublescalar value representing the probability of success on each independent trial, \(p\)- Returns:
- a
double, the probability density atxgiven the parameter value, \(p\)
-
getPDFGradient
public double[] getPDFGradient(double x, double... params) Returns the analytic gradient of the pdf.- Specified by:
getPDFGradientin interfacePDFGradientInterface- Parameters:
x- adouble, the value at which to evaluate the pdf.xmust be a non-negative integer. Ifxis not an integer, thenxis cast to an integer.params- adouble, the value of the parameter \(p\)- Returns:
- a
doublearray containing the first partial derivative of the pdf with respect to the parameter
-
getPDFHessian
public double[][] getPDFHessian(double x, double... params) Returns the analytic Hessian matrix of the pdf.- Specified by:
getPDFHessianin interfacePDFHessianInterface- Parameters:
x- adouble, the value at which to evaluate the Hessian.xmust be a non-negative integer. Ifxis not an integer, the integer cast value will be used.params- adouble, the value of the parameter \(p\)- Returns:
- a
doublematrix containing the second partial derivative of the pdf with respect to the parameter
-
getClosedFormMLE
public double[] getClosedFormMLE(double[] x) Returns the closed form maximum likelihood estimate.- Specified by:
getClosedFormMLEin interfaceClosedFormMaximumLikelihoodInterface- Parameters:
x- adoublearray containing the data- Returns:
- a
doublearray containing the maximum likelihood estimate
-
getClosedFormMlStandardError
public double[] getClosedFormMlStandardError(double[] x) Returns the standard error based on the closed form maximum likelihood estimate.- Specified by:
getClosedFormMlStandardErrorin interfaceClosedFormMaximumLikelihoodInterface- Parameters:
x- adoublearray containing the data- Returns:
- a
doublearray containing the standard error
-
setNumberOfSuccesses
public void setNumberOfSuccesses(int numSuccesses) Sets the number of successes.- Parameters:
numSuccesses- anint, the number of successes. The default isnumSuccesses=1.
-
getNumberOfSuccesses
public int getNumberOfSuccesses()Returns the number of successes.- Returns:
- an
int, the number of successes set
-