org.apache.commons.math.distribution
Class AbstractDistribution

java.lang.Object
  extended by org.apache.commons.math.distribution.AbstractDistribution
All Implemented Interfaces:
java.io.Serializable, Distribution
Direct Known Subclasses:
AbstractContinuousDistribution, AbstractIntegerDistribution

public abstract class AbstractDistribution
extends java.lang.Object
implements Distribution, java.io.Serializable

Base class for probability distributions.

Version:
$Id: AbstractDistribution.java 1178295 2011-10-03 04:36:27Z psteitz $
See Also:
Serialized Form

Constructor Summary
protected AbstractDistribution()
          Default constructor.
 
Method Summary
protected abstract  double calculateNumericalMean()
          Use this method to actually calculate the mean for the specific distribution.
protected abstract  double calculateNumericalVariance()
          Use this method to actually calculate the variance for the specific distribution.
 double cumulativeProbability(double x0, double x1)
          For a random variable X whose values are distributed according to this distribution, this method returns P(x0 ≤ X ≤ x1).
 double getNumericalMean()
          Use this method to get the numerical value of the mean of this distribution.
 double getNumericalVariance()
          Use this method to get the numerical value of the variance of this distribution.
 boolean isSupportConnected()
          Use this method to get information about whether the support is connected, i.e. whether all values between the lower and upper bound of the support is included in the support.
abstract  boolean isSupportLowerBoundInclusive()
          Use this method to get information about whether the lower bound of the support is inclusive or not.
abstract  boolean isSupportUpperBoundInclusive()
          Use this method to get information about whether the upper bound of the support is inclusive or not.
 
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.Distribution
cumulativeProbability
 

Constructor Detail

AbstractDistribution

protected AbstractDistribution()
Default constructor.

Method Detail

cumulativeProbability

public double cumulativeProbability(double x0,
                                    double x1)
For a random variable X whose values are distributed according to this distribution, this method returns P(x0 ≤ X ≤ x1).

The default implementation uses the identity

P(x0 ≤ X ≤ x1) = P(X ≤ x1) - P(X ≤ x0)

Specified by:
cumulativeProbability in interface Distribution
Parameters:
x0 - the (inclusive) lower bound
x1 - the (inclusive) upper bound
Returns:
the probability that a random variable with this distribution will take a value between x0 and x1, including the endpoints.
Throws:
NumberIsTooLargeException - if x0 > x1

calculateNumericalMean

protected abstract double calculateNumericalMean()
Use this method to actually calculate the mean for the specific distribution. Use getNumericalMean() (which implements caching) to actually get the mean.

Returns:
the mean or Double.NaN if it's not defined

getNumericalMean

public double getNumericalMean()
Use this method to get the numerical value of the mean of this distribution.

Specified by:
getNumericalMean in interface Distribution
Returns:
the mean or Double.NaN if it's not defined

calculateNumericalVariance

protected abstract double calculateNumericalVariance()
Use this method to actually calculate the variance for the specific distribution. Use getNumericalVariance() (which implements caching) to actually get the variance.

Returns:
the variance or Double.NaN if it's not defined

getNumericalVariance

public double getNumericalVariance()
Use this method to get the numerical value of the variance of this distribution.

Specified by:
getNumericalVariance in interface Distribution
Returns:
the variance (possibly Double.POSITIVE_INFINITY as for certain cases in TDistributionImpl) or Double.NaN if it's not defined

isSupportLowerBoundInclusive

public abstract boolean isSupportLowerBoundInclusive()
Use this method to get information about whether the lower bound of the support is inclusive or not.

Specified by:
isSupportLowerBoundInclusive in interface Distribution
Returns:
whether the lower bound of the support is inclusive or not

isSupportUpperBoundInclusive

public abstract boolean isSupportUpperBoundInclusive()
Use this method to get information about whether the upper bound of the support is inclusive or not.

Specified by:
isSupportUpperBoundInclusive in interface Distribution
Returns:
whether the upper bound of the support is inclusive or not

isSupportConnected

public boolean isSupportConnected()
Use this method to get information about whether the support is connected, i.e. whether all values between the lower and upper bound of the support is included in the support. For AbstractIntegerDistribution the support is discrete, so if this is true, then the support is {lower bound, lower bound + 1, ..., upper bound}. For AbstractContinuousDistribution the support is continuous, so if this is true, then the support is the interval [lower bound, upper bound] where the limits are inclusive or not according to isSupportLowerBoundInclusive() and isSupportUpperBoundInclusive() (in the example both are true). If both are false, then the support is the interval (lower bound, upper bound)

Specified by:
isSupportConnected in interface Distribution
Returns:
whether the support limits given by subclassed methods are connected or not


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.