net.sf.doodleproject.numerics4j.statistics.distribution
Class BinomialDistribution

java.lang.Object
  extended by net.sf.doodleproject.numerics4j.statistics.distribution.DiscreteDistribution
      extended by net.sf.doodleproject.numerics4j.statistics.distribution.BinomialDistribution
All Implemented Interfaces:
Distribution

public class BinomialDistribution
extends DiscreteDistribution

The Binomial distribution.

References:

  1. Eric W. Weisstein. "Binomial Distribution." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/BinomialDistribution.html

Since:
1.2
Version:
$Revision: 1.2 $ $Date: 2007/10/25 04:44:10 $

Constructor Summary
BinomialDistribution()
          Default constructor.
BinomialDistribution(int n, double p)
          Create a distribution with the given number of trials and probability of success.
 
Method Summary
 double cumulativeProbability(int x)
          The CDF for this distribution.
 int getNumberOfTrials()
          Access the number of trials.
 double getProbabilityOfSuccess()
          Access probability of success.
 int inverseCumulativeProbability(double p)
          The inverse CDF for this distribution.
 double probability(int x)
          The PMF for this distribution.
 void setNumberOfTrials(int n)
          Modify the number of trials.
 void setProbabilityOfSuccess(double p)
          Modify probability of success.
 
Methods inherited from class net.sf.doodleproject.numerics4j.statistics.distribution.DiscreteDistribution
findInverseCumulativeProbability, simpleCumulativeProbability
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinomialDistribution

public BinomialDistribution()
Default constructor. Number of trials is set to one and probability of success is set to 0.5.


BinomialDistribution

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

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

cumulativeProbability

public double cumulativeProbability(int x)
                             throws NumericException
The CDF for this distribution. This method returns P(X ≤ x).

Specified by:
cumulativeProbability in class DiscreteDistribution
Parameters:
x - the value at which the CDF is evaluated.
Returns:
CDF for this distribution.
Throws:
NumericException - if the cumulative probability can not be computed.

getNumberOfTrials

public int getNumberOfTrials()
Access the number of trials.

Returns:
the number of trials.

getProbabilityOfSuccess

public double getProbabilityOfSuccess()
Access probability of success.

Returns:
the probability of success.

inverseCumulativeProbability

public int inverseCumulativeProbability(double p)
                                 throws NumericException
The inverse CDF for this distribution. This method returns the largest x such that, P(X ≤ x) ≤ p. The return value must also satisfy P(X ≥ x) &ge 1 - p.

Specified by:
inverseCumulativeProbability in class DiscreteDistribution
Parameters:
p - the cumulative probability.
Returns:
x
Throws:
NumericException - if the inverse cumulative probability can not be computed.

probability

public double probability(int x)
The PMF for this distribution. This method returns P(X = x).

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

setNumberOfTrials

public void setNumberOfTrials(int n)
Modify the number of trials.

Parameters:
n - the new number of trials value.

setProbabilityOfSuccess

public void setProbabilityOfSuccess(double p)
Modify probability of success.

Parameters:
p - the new probability of success value.


Copyright 2004-2004-2007 DoodleProject. All Rights Reserved.