|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.random.EmpiricalDistributionImpl
Implements EmpiricalDistribution
interface. This implementation
uses what amounts to the
Variable Kernel Method with Gaussian smoothing:
Digesting the input file
binCount
"bins."USAGE NOTES:
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.
Nested Class Summary | |
private class |
EmpiricalDistributionImpl.ArrayDataAdapter
DataAdapter for data provided as array of doubles. |
private class |
EmpiricalDistributionImpl.DataAdapter
Provides methods for computing sampleStats and
beanStats abstracting the source of data. |
private class |
EmpiricalDistributionImpl.DataAdapterFactory
Factory of DataAdapter objects. |
private class |
EmpiricalDistributionImpl.StreamDataAdapter
DataAdapter for data provided through some input stream |
Field Summary | |
private int |
binCount
number of bins |
private java.util.ArrayList |
binStats
List of SummaryStatistics objects characterizing the bins |
private boolean |
loaded
is the distribution loaded? |
private RandomData |
randomData
RandomData instance to use in repeated calls to getNext() |
(package private) SummaryStatistics |
sampleStats
Sample statistics |
(package private) static long |
serialVersionUID
Serializable version identifier |
private double[] |
upperBounds
upper bounds of subintervals in (0,1) "belonging" to the bins |
Constructor Summary | |
EmpiricalDistributionImpl()
Creates a new EmpiricalDistribution with the default bin count. |
|
EmpiricalDistributionImpl(int binCount)
Creates a new EmpiricalDistribution with the specified bin count. |
Method Summary | |
private void |
fillBinStats(java.lang.Object in)
Fills binStats array (second pass through data file). |
int |
getBinCount()
Returns the number of bins. |
java.util.List |
getBinStats()
Returns an ArrayList of SummaryStatistics instances 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[] in)
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static final long serialVersionUID
private java.util.ArrayList binStats
SummaryStatistics sampleStats
private int binCount
private boolean loaded
private double[] upperBounds
private RandomData randomData
Constructor Detail |
public EmpiricalDistributionImpl()
public EmpiricalDistributionImpl(int binCount)
binCount
- number of binsMethod Detail |
public void load(double[] in)
load
in interface EmpiricalDistribution
in
- the input data arraypublic void load(java.net.URL url) throws java.io.IOException
load
in interface EmpiricalDistribution
url
- url of the input file
java.io.IOException
- if an IO error occurspublic void load(java.io.File file) throws java.io.IOException
load
in interface EmpiricalDistribution
file
- the input file
java.io.IOException
- if an IO error occursprivate void fillBinStats(java.lang.Object in) throws java.io.IOException
in
- object providing access to the data
java.io.IOException
- if an IO error occurspublic double getNextValue() throws java.lang.IllegalStateException
getNextValue
in interface EmpiricalDistribution
java.lang.IllegalStateException
- if the distribution has not been loadedpublic StatisticalSummary getSampleStats()
StatisticalSummary
describing this distribution.
Preconditions:
getSampleStats
in interface EmpiricalDistribution
java.lang.IllegalStateException
- if the distribution has not been loadedpublic int getBinCount()
getBinCount
in interface EmpiricalDistribution
public java.util.List getBinStats()
SummaryStatistics
instances containing
statistics describing the values in each of the bins. The ArrayList is
indexed on the bin number.
getBinStats
in interface EmpiricalDistribution
public double[] getUpperBounds()
getUpperBounds
in interface EmpiricalDistribution
public boolean isLoaded()
isLoaded
in interface EmpiricalDistribution
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |