org.apache.commons.math.distribution
Class BinomialDistributionImpl

java.lang.Object
  extended byorg.apache.commons.math.distribution.AbstractDiscreteDistribution
      extended byorg.apache.commons.math.distribution.BinomialDistributionImpl
All Implemented Interfaces:
BinomialDistribution, DiscreteDistribution, Serializable

public class BinomialDistributionImpl
extends AbstractDiscreteDistribution
implements BinomialDistribution, Serializable

The default implementation of BinomialDistribution.

Version:
$Revision: 1.8 $ $Date: 2003/11/19 03:22:53 $
See Also:
Serialized Form

Constructor Summary
BinomialDistributionImpl(int trials, double p)
          Create a binomial distribution with the given number of trials and probability of success.
 
Method Summary
 double cummulativeProbability(int x)
          For this disbution, X, this method returns P(X ≤ x).
protected  int getDomainLowerBound(double p)
          Access the domain value lower bound, based on p, used to bracket a PDF root.
protected  int getDomainUpperBound(double p)
          Access the domain value upper bound, based on p, used to bracket a PDF root.
 int getNumberOfTrials()
          Access the number of trials for this distribution.
 double getProbabilityOfSuccess()
          Access the probability of success for this distribution.
 double probability(int x)
          For this disbution, X, this method returns P(X = x).
 void setNumberOfTrials(int trials)
          Change the number of trials for this distribution.
 void setProbabilityOfSuccess(double p)
          Change the probability of success for this distribution.
 
Methods inherited from class org.apache.commons.math.distribution.AbstractDiscreteDistribution
cummulativeProbability, inverseCummulativeProbability
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.math.distribution.DiscreteDistribution
cummulativeProbability, inverseCummulativeProbability
 

Constructor Detail

BinomialDistributionImpl

public BinomialDistributionImpl(int trials,
                                double p)
Create a binomial distribution with the given number of trials and probability of success.

Parameters:
trials - the number of trials.
p - the probability of success.
Method Detail

getNumberOfTrials

public int getNumberOfTrials()
Access the number of trials for this distribution.

Specified by:
getNumberOfTrials in interface BinomialDistribution
Returns:
the number of trials.

getProbabilityOfSuccess

public double getProbabilityOfSuccess()
Access the probability of success for this distribution.

Specified by:
getProbabilityOfSuccess in interface BinomialDistribution
Returns:
the probability of success.

setNumberOfTrials

public void setNumberOfTrials(int trials)
Change the number of trials for this distribution.

Specified by:
setNumberOfTrials in interface BinomialDistribution
Parameters:
trials - the new number of trials.

setProbabilityOfSuccess

public void setProbabilityOfSuccess(double p)
Change the probability of success for this distribution.

Specified by:
setProbabilityOfSuccess in interface BinomialDistribution
Parameters:
p - the new probability of success.

getDomainLowerBound

protected int getDomainLowerBound(double p)
Access the domain value lower bound, based on p, used to bracket a PDF root.

Specified by:
getDomainLowerBound in class AbstractDiscreteDistribution
Parameters:
p - the desired probability for the critical value
Returns:
domain value lower bound, i.e. P(X < lower bound) < p

getDomainUpperBound

protected int getDomainUpperBound(double p)
Access the domain value upper bound, based on p, used to bracket a PDF root.

Specified by:
getDomainUpperBound in class AbstractDiscreteDistribution
Parameters:
p - the desired probability for the critical value
Returns:
domain value upper bound, i.e. P(X < upper bound) > p

cummulativeProbability

public double cummulativeProbability(int x)
                              throws MathException
For this disbution, X, this method returns P(X ≤ x).

Specified by:
cummulativeProbability in interface DiscreteDistribution
Parameters:
x - the value at which the PDF is evaluated.
Returns:
PDF for this distribution.
Throws:
MathException

probability

public double probability(int x)
For this disbution, X, this method returns P(X = x).

Specified by:
probability in interface DiscreteDistribution
Parameters:
x - the value at which the PMF is evaluated.
Returns:
PMF for this distribution.


Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.