Java Statistical Classes

jsc.distributions
Class AbstractDistribution

java.lang.Object
  |
  +--jsc.distributions.AbstractDistribution
All Implemented Interfaces:
Distribution
Direct Known Subclasses:
AbstractContinuousDistribution, AbstractDiscreteDistribution, Beta, Cauchy, Discrete, Exponential, ExtremeValue, FishersF, Gamma, Geometric, Geometric1, Laplace, LogarithmicSeries, Logistic, Lognormal, NegativeBinomial, Normal, Pareto, Poisson, PowerFunction, StudentsT, Uniform, Weibull

public abstract class AbstractDistribution
extends Object
implements Distribution

Root class for classes that implement the Distribution interface. It defines a default method to return random values from the distribution, and some other useful methods.

The constructor creates a pseudo-random number generator for use by subclassed specific distributions - especially through Random.nextDouble() which produces values from U(0,1) that is the basis of random number generators for all distributions. But note that setSeed(long) should be used to avoid different instances producing the same, or correlated, random values.

Version:
1.0
Author:
A. J. Bertie.

Field Summary
protected  Random rand
          Pseudo-random number generator for use by subclassed specific distributions.
 
Constructor Summary
AbstractDistribution()
          Creates a pseudo-random number generator for use by subclassed specific distributions
 
Method Summary
abstract  double cdf(double x)
          Returns the value of the cumulative density function at a variate-value x.
abstract  double inverseCdf(double p)
          Returns the rth moment about an arbitrary point, a.
 boolean isDiscrete()
          Returns false indicating that the distribution is continuous.
abstract  double mean()
          Returns mean of the distribution if it exists.
abstract  double pdf(double x)
          Returns the value of the probability density (or mass) function at a variate-value x.
 double random()
          Returns a pseudo-random variate-value from the distribution.
 double sd()
          Returns the standard deviation of the distribution if it exists.
 void setSeed(long seed)
          Initialize the random number generator with a seed value.
abstract  double variance()
          Returns variance of the distribution if it exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rand

protected Random rand
Pseudo-random number generator for use by subclassed specific distributions. rand.nextDouble() produces values from U(0,1) that is the basis of all random number generators.

Constructor Detail

AbstractDistribution

public AbstractDistribution()
Creates a pseudo-random number generator for use by subclassed specific distributions

Method Detail

cdf

public abstract double cdf(double x)
Description copied from interface: Distribution
Returns the value of the cumulative density function at a variate-value x.

Specified by:
cdf in interface Distribution
Parameters:
x - a valid variate-value from the distribution.
Returns:
the value of the cumulative density function at x.

inverseCdf

public abstract double inverseCdf(double p)
Returns the rth moment about an arbitrary point, a.

Specified by:
inverseCdf in interface Distribution
Parameters:
p - the value of the probability; must be greater than or equal to 0 and less than or equal to 1. Implemented methods may be more restrictive with respect to values close to, or equal to, 0 or 1.
Returns:
the moment of order r about a.

isDiscrete

public boolean isDiscrete()
Returns false indicating that the distribution is continuous. Discrete distributions should override this method to return true.

Specified by:
isDiscrete in interface Distribution
Returns:
false.

mean

public abstract double mean()
Description copied from interface: Distribution
Returns mean of the distribution if it exists. If the mean does not exist, returns Double.NaN.

Specified by:
mean in interface Distribution
Returns:
mean of the distribution.

pdf

public abstract double pdf(double x)
Description copied from interface: Distribution
Returns the value of the probability density (or mass) function at a variate-value x. Returns the value of the probability density for a continuous distribution, or the value of the probability mass function for a discrete distribution.

Specified by:
pdf in interface Distribution
Parameters:
x - a valid variate-value from the distribution.
Returns:
the value of the pdf (or pmf) at x.

random

public double random()
Returns a pseudo-random variate-value from the distribution. This is a default implementation that uses the probability integral transformation. That is, it returns the value of the inverse of the distribution function at a pseudo-random value from the continuous uniform distribution U(0,1). The probability integral transformation will generally be far less efficient than a method developed for the specific distribution, so this method should be overridden wherever possible.

Specified by:
random in interface Distribution
Returns:
a pseudo-random variate-value from the distribution.

sd

public double sd()
Returns the standard deviation of the distribution if it exists. If the variance does not exist, returns Double.NaN. This default implementation returns the positive square root of the variance.

Returns:
the standard deviation.

setSeed

public void setSeed(long seed)
Initialize the random number generator with a seed value. N.B. Use this with different seed values if two or more distributions created close together in code: default clock seed may be same resulting in correlated random values.

Specified by:
setSeed in interface Distribution
Parameters:
seed - a seed value.

variance

public abstract double variance()
Description copied from interface: Distribution
Returns variance of the distribution if it exists. If the variance does not exist, returns Double.NaN.

Specified by:
variance in interface Distribution
Returns:
the variance of the distribution.

Java Statistical Classes

Copyright © Andrew James Bertie, 2005, all rights reserved. Updated 12th Aug 2005