Package com.imsl.stat.distributions
Class BinomialPD
java.lang.Object
com.imsl.stat.distributions.ProbabilityDistribution
com.imsl.stat.distributions.BinomialPD
- All Implemented Interfaces:
ClosedFormMaximumLikelihoodInterface,com.imsl.stat.distributions.MethodOfMomentsInterface,PDFGradientInterface,PDFHessianInterface,Serializable,Cloneable
public class BinomialPD
extends ProbabilityDistribution
implements Serializable, Cloneable, PDFHessianInterface, ClosedFormMaximumLikelihoodInterface, com.imsl.stat.distributions.MethodOfMomentsInterface
The 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.double[]getMethodOfMomentsEstimates(double[] x) Returns the Method of Moments estimate given the sample data.intReturns the number of independent Bernoulli trials.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 binomial probability density function.voidsetNumberOfTrials(int numTrials) Sets the number of independent Bernoulli trials.Methods inherited from class com.imsl.stat.distributions.ProbabilityDistribution
getNumberOfParameters, getPDFGradientApproximation, getPDFHessianApproximation, getRangeOfX, setRangeOfX
-
Constructor Details
-
BinomialPD
public BinomialPD()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 binomial probability density function.The probability density function of the binomial distribution is $$f(k,n,p) = \Pr \left( {X = k} \right) = {n \choose k} p^k(1-p)^{n-k} \quad \text{for}\;k=0, 1, 2, \ldots, n$$
where \(k\) is the number of successes in \(n\) independent Bernoulli trials, \(n \in \{1, 2, \ldots\}\), and \(p \in [0,1]\) is the success probability in each trial.- Specified by:
pdfin classProbabilityDistribution- Parameters:
x- adouble, the value (quantile) at which to evaluate the pdf.xmust be a non-negative integer in the interval \([0,n]\), where \(n\) is the number of independent trials. Ifxis not a whole number,xis cast to anint. The number of trials can be set via methodsetNumberOfTrials(int).params- adoublescalar value representing the probability of success on each independent trial, \(p\)- Returns:
- a
double, the probability density atxgiven the parameter value
-
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 in the interval \([0,n]\), where \(n\) is the number of independent trials. Ifxis not a whole number,xis cast to anint.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 a whole numberxis cast to anint.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
-
getMethodOfMomentsEstimates
public double[] getMethodOfMomentsEstimates(double[] x) Returns the Method of Moments estimate given the sample data.- Specified by:
getMethodOfMomentsEstimatesin interfacecom.imsl.stat.distributions.MethodOfMomentsInterface- Parameters:
x- adoublearray containing the data- Returns:
- a
doublearray containing the Method of Moments estimate for the parameter of the binomial distribution
-
setNumberOfTrials
public void setNumberOfTrials(int numTrials) Sets the number of independent Bernoulli trials.- Parameters:
numTrials- anint, the number of trials. The default isnumTrials=1, that is, one Bernoulli trial.
-
getNumberOfTrials
public int getNumberOfTrials()Returns the number of independent Bernoulli trials.- Returns:
- an
int, the number of independent Bernoulli trials used
-