Java Statistical Classes

jsc.distributions
Class Exponential

java.lang.Object
  |
  +--jsc.distributions.AbstractDistribution
        |
        +--jsc.distributions.Exponential
All Implemented Interfaces:
Distribution

public class Exponential
extends AbstractDistribution

This class represents an exponential distribution.

Note that here the distribution is defined in terms of its mean. (Some textbooks define the distribution differently in terms of a parameter that is the reciprocal of the mean.)

This could have been defined as a subclass of Gamma or Weibull with shape parameter = 1, but not done so since calculations for exponential are so much simpler.

Version:
1.0
Author:
A. J. Bertie.

Field Summary
 
Fields inherited from class jsc.distributions.AbstractDistribution
rand
 
Constructor Summary
Exponential()
          Create an exponential distribution with mean 1.
Exponential(double mean)
          Create an exponential distribution with specified mean.
 
Method Summary
 double cdf(double x)
          Returns the value of the cumulative density function at a variate-value x.
 double getMaximumPdf()
          Returns the maximum value of the pdf of the distribution.
 double inverseCdf(double p)
          Returns the inverse of the distribution.
 double mean()
          Returns mean of the distribution if it exists.
 double pdf(double x)
          Returns the value of the probability density function at variate-value x.
 double random()
          Returns a pseudo-random variate-value from the distribution.
 double sd()
          Returns the standard deviation of the distribution.
 void setMean(double mean)
          Sets the mean of the distribution.
 String toString()
           
 double variance()
          Returns variance of the distribution if it exists.
 
Methods inherited from class jsc.distributions.AbstractDistribution
isDiscrete, setSeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Exponential

public Exponential(double mean)
Create an exponential distribution with specified mean.

Parameters:
mean - the parameter (mean) of the distribution; must be greater than 0.
Throws:
IllegalArgumentException - if mean less than or equal to 0.

Exponential

public Exponential()
Create an exponential distribution with mean 1.

Method Detail

cdf

public double cdf(double x)
Returns the value of the cumulative density function at a variate-value x.

Specified by:
cdf in interface Distribution
Specified by:
cdf in class AbstractDistribution
Parameters:
x - a variate-value; must be greater than or equal to zero.
Returns:
the value of the cdf at x.
Throws:
IllegalArgumentException - if x less than 0.

getMaximumPdf

public double getMaximumPdf()
Returns the maximum value of the pdf of the distribution.

Returns:
the maximum value of the pdf.

inverseCdf

public double inverseCdf(double p)
Returns the inverse of the distribution. Given a probability p, returns the value of x such that Prob(X <= x) = p.

Specified by:
inverseCdf in interface Distribution
Specified by:
inverseCdf in class AbstractDistribution
Parameters:
p - the value of the probability; must be in [0,1].
Returns:
the variate-value x; returns Double.POSITIVE_INFINITY if p=1.
Throws:
IllegalArgumentException - if p is less than 0 or greater than 1.

mean

public 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
Specified by:
mean in class AbstractDistribution
Returns:
mean of the distribution.

pdf

public double pdf(double x)
Returns the value of the probability density function at variate-value x.

Specified by:
pdf in interface Distribution
Specified by:
pdf in class AbstractDistribution
Parameters:
x - a variate-value; must be greater than or equal to zero.
Returns:
the value of the pdf at x.
Throws:
IllegalArgumentException - if x less than 0.

random

public double random()
Description copied from class: AbstractDistribution
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
Overrides:
random in class AbstractDistribution
Returns:
a pseudo-random variate-value from the distribution.

sd

public double sd()
Returns the standard deviation of the distribution.

Overrides:
sd in class AbstractDistribution
Returns:
the standard deviation of the distribution.

setMean

public void setMean(double mean)
Sets the mean of the distribution.

Parameters:
mean - the parameter (mean) of the distribution; must be greater than 0.
Throws:
IllegalArgumentException - if b less than or equal to 0.

toString

public String toString()
Overrides:
toString in class Object

variance

public 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
Specified by:
variance in class AbstractDistribution
Returns:
the variance of the distribution.

Java Statistical Classes

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