org.apache.commons.math.random
Interface EmpiricalDistribution

All Known Implementing Classes:
EmpiricalDistributionImpl

public interface EmpiricalDistribution

Represents an empirical probability distribution -- a probability distribution derived from observed data without making any assumptions about the functional form of the population distribution that the data come from.

Implementations of this interface maintain data structures, called distribution digests, that describe empirical distributions and support the following operations:

Applications can use EmpiricalDistribution implementations to build grouped frequnecy histograms representing the input data or to generate random values "like" those in the input file -- i.e., the values generated will follow the distribution of the values in the file.

Version:
$Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $

Method Summary
 int getBinCount()
          Returns the number of bins.
 java.util.List getBinStats()
          Returns a list of SummaryStatistics containing statistics describing the values in each of the bins.
 double getNextValue()
          Generates a random value from this distribution.
 StatisticalSummary getSampleStats()
          Returns a StatisticalSummary describing this distribution.
 double[] getUpperBounds()
          Returns the array of upper bounds for the bins.
 boolean isLoaded()
          Property indicating whether or not the distribution has been loaded.
 void load(double[] dataArray)
          Computes the empirical distribution from the provided array of numbers.
 void load(java.io.File file)
          Computes the empirical distribution from the input file.
 void load(java.net.URL url)
          Computes the empirical distribution using data read from a URL.
 

Method Detail

load

void load(double[] dataArray)
Computes the empirical distribution from the provided array of numbers.

Parameters:
dataArray - the data array

load

void load(java.io.File file)
          throws java.io.IOException
Computes the empirical distribution from the input file.

Parameters:
file - the input file
Throws:
java.io.IOException - if an IO error occurs

load

void load(java.net.URL url)
          throws java.io.IOException
Computes the empirical distribution using data read from a URL.

Parameters:
url - url of the input file
Throws:
java.io.IOException - if an IO error occurs

getNextValue

double getNextValue()
                    throws java.lang.IllegalStateException
Generates a random value from this distribution. Preconditions:

Returns:
the random value.
Throws:
java.lang.IllegalStateException - if the distribution has not been loaded

getSampleStats

StatisticalSummary getSampleStats()
                                  throws java.lang.IllegalStateException
Returns a StatisticalSummary describing this distribution. Preconditions:

Returns:
the sample statistics
Throws:
java.lang.IllegalStateException - if the distribution has not been loaded

isLoaded

boolean isLoaded()
Property indicating whether or not the distribution has been loaded.

Returns:
true if the distribution has been loaded

getBinCount

int getBinCount()
Returns the number of bins.

Returns:
the number of bins

getBinStats

java.util.List getBinStats()
Returns a list of SummaryStatistics containing statistics describing the values in each of the bins. The List is indexed on the bin number.

Returns:
List of bin statistics

getUpperBounds

double[] getUpperBounds()
Returns the array of upper bounds for the bins. Bins are:
[min,upperBounds[0]],(upperBounds[0],upperBounds[1]],..., (upperBounds[binCount-1],max].

Returns:
array of bin upper bounds