| java.lang.Object org.apache.commons.math.random.EmpiricalDistributionImpl
EmpiricalDistributionImpl | public class EmpiricalDistributionImpl implements Serializable,EmpiricalDistribution(Code) | | Implements EmpiricalDistribution interface. This implementation
uses what amounts to the
Variable Kernel Method with Gaussian smoothing:
Digesting the input file
- Pass the file once to compute min and max.
- Divide the range from min-max into
binCount "bins."
- Pass the data file again, computing bin counts and univariate
statistics (mean, std dev.) for each of the bins
- Divide the interval (0,1) into subintervals associated with the bins,
with the length of a bin's subinterval proportional to its count.
Generating random values from the distribution
- Generate a uniformly distributed value in (0,1)
- Select the subinterval to which the value belongs.
- Generate a random Gaussian value with mean = mean of the associated
bin and std dev = std dev of associated bin.
USAGE NOTES:
- The
binCount is set by default to 1000. A good rule of thumb
is to set the bin count to approximately the length of the input file divided
by 10.
- The input file must be a plain text file containing one valid numeric
entry per line.
version: $Revision: 348894 $ $Date: 2005-11-24 23:34:47 -0700 (Thu, 24 Nov 2005) $ |
Method Summary | |
public int | getBinCount() Returns the number of bins. | public List | getBinStats() Returns an ArrayList of
SummaryStatistics instances containing
statistics describing the values in each of the bins. | public double | getNextValue() Generates a random value from this distribution. | public StatisticalSummary | getSampleStats() Returns a
StatisticalSummary describing this distribution. | public double[] | getUpperBounds() Returns (a fresh copy of) the array of upper bounds for the bins. | public boolean | isLoaded() Property indicating whether or not the distribution has been loaded. | public void | load(double[] in) Computes the empirical distribution from the provided
array of numbers. | public void | load(URL url) Computes the empirical distribution using data read from a URL. | public void | load(File file) Computes the empirical distribution from the input file. |
EmpiricalDistributionImpl | public EmpiricalDistributionImpl()(Code) | | Creates a new EmpiricalDistribution with the default bin count.
|
EmpiricalDistributionImpl | public EmpiricalDistributionImpl(int binCount)(Code) | | Creates a new EmpiricalDistribution with the specified bin count.
Parameters: binCount - number of bins |
getBinCount | public int getBinCount()(Code) | | Returns the number of bins.
the number of bins. |
getBinStats | public List getBinStats()(Code) | | Returns an ArrayList of
SummaryStatistics instances containing
statistics describing the values in each of the bins. The ArrayList is
indexed on the bin number.
List of bin statistics. |
getUpperBounds | public double[] getUpperBounds()(Code) | | Returns (a fresh copy of) the array of upper bounds for the bins.
Bins are:
[min,upperBounds[0]],(upperBounds[0],upperBounds[1]],...,
(upperBounds[binCount-1],max]
array of bin upper bounds |
isLoaded | public boolean isLoaded()(Code) | | Property indicating whether or not the distribution has been loaded.
true if the distribution has been loaded |
load | public void load(double[] in)(Code) | | Computes the empirical distribution from the provided
array of numbers.
Parameters: in - the input data array |
load | public void load(URL url) throws IOException(Code) | | Computes the empirical distribution using data read from a URL.
Parameters: url - url of the input file throws: IOException - if an IO error occurs |
load | public void load(File file) throws IOException(Code) | | Computes the empirical distribution from the input file.
Parameters: file - the input file throws: IOException - if an IO error occurs |
|
|