Class 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 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:
      getParameterLowerBounds in class ProbabilityDistribution
      Returns:
      a double array of length 1 containing the lower bound for \(p\)
    • getParameterUpperBounds

      public double[] getParameterUpperBounds()
      Returns the upper bound of the parameter.
      Specified by:
      getParameterUpperBounds in class ProbabilityDistribution
      Returns:
      a double array 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:
      pdf in class ProbabilityDistribution
      Parameters:
      x - a double, the value (quantile) at which to evaluate the pdf. x must be a non-negative integer in the interval \([0,n]\), where \(n\) is the number of independent trials. If x is not a whole number, x is cast to an int. The number of trials can be set via method setNumberOfTrials(int).
      params - a double scalar value representing the probability of success on each independent trial, \(p\)
      Returns:
      a double, the probability density at x given the parameter value
    • getPDFGradient

      public double[] getPDFGradient(double x, double... params)
      Returns the analytic gradient of the pdf.
      Specified by:
      getPDFGradient in interface PDFGradientInterface
      Parameters:
      x - a double, the value at which to evaluate the pdf. x must be a non-negative integer in the interval \([0,n]\), where \(n\) is the number of independent trials. If x is not a whole number, x is cast to an int.
      params - a double, the value of the parameter \(p\)
      Returns:
      a double array 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:
      getPDFHessian in interface PDFHessianInterface
      Parameters:
      x - a double, the value at which to evaluate the Hessian. x must be a non-negative integer. If x is not a whole number x is cast to an int.
      params - a double, the value of the parameter \(p\)
      Returns:
      a double matrix 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:
      getClosedFormMLE in interface ClosedFormMaximumLikelihoodInterface
      Parameters:
      x - a double array containing the data
      Returns:
      a double array 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:
      getClosedFormMlStandardError in interface ClosedFormMaximumLikelihoodInterface
      Parameters:
      x - a double array containing the data
      Returns:
      a double array containing the standard error
    • getMethodOfMomentsEstimates

      public double[] getMethodOfMomentsEstimates(double[] x)
      Returns the Method of Moments estimate given the sample data.
      Specified by:
      getMethodOfMomentsEstimates in interface com.imsl.stat.distributions.MethodOfMomentsInterface
      Parameters:
      x - a double array containing the data
      Returns:
      a double array 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 - an int, the number of trials. The default is numTrials=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