public class UnivariateMixtureEstimator extends java.lang.Object implements UnivariateDensityEstimator, UnivariateIntervalEstimator, UnivariateQuantileEstimator, OptionHandler, java.io.Serializable
| Modifier and Type | Class and Description |
|---|---|
class |
UnivariateMixtureEstimator.MM
Fast univariate mixture model implementation.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_Debug
Whether to output debug info.
|
protected int |
m_MaxNumComponents
The maximum number of components to use (default is 5)
|
protected UnivariateMixtureEstimator.MM |
m_MixtureModel
The current mixture model
|
protected int |
m_NumBootstrapRuns
The number of Bootstrap runs to use to select the number of components (default is 10)
|
protected int |
m_NumComponents
The number of components to use (default is -1)
|
protected int |
m_NumIntervals
The number of intervals used to approximate prediction interval.
|
protected int |
m_NumValues
The number of values that have been seen
|
protected java.util.Random |
m_Random
The random number generator.
|
protected int |
m_Seed
The random number seed to use (default is 1
|
protected boolean |
m_UseNormalizedEntropy
Whether to use normalized entropy instance of bootstrap.
|
protected double[] |
m_Values
The values used for this estimator
|
protected double[] |
m_Weights
The weights used for this estimator
|
| Constructor and Description |
|---|
UnivariateMixtureEstimator() |
| Modifier and Type | Method and Description |
|---|---|
void |
addValue(double value,
double weight)
Adds a value to the density estimator.
|
UnivariateMixtureEstimator.MM |
buildModel(int K,
double[] values,
double[] weights)
Build mixture model.
|
protected double |
entropy(UnivariateMixtureEstimator.MM mixtureModel)
Calculates entrpy for given model and data.
|
protected UnivariateMixtureEstimator.MM |
findModelUsingNormalizedEntropy()
Selects the number of components using normalized entropy.
|
protected int |
findNumComponentsUsingBootStrap()
Selects the number of components using leave-one-out Bootstrap, estimating loglikelihood.
|
int |
getMaxNumComponents()
Returns the number of components to use.
|
int |
getNumBootstrapRuns()
Returns the number of Bootstrap runs.
|
int |
getNumComponents()
Returns the number of components to use.
|
java.lang.String[] |
getOptions()
Returns the current set of options.
|
java.lang.String |
getRevision()
Returns the revision string.
|
int |
getSeed()
Gets the seed for the random number generations
|
boolean |
getUseNormalizedEntropy() |
java.lang.String |
globalInfo()
Returns a string describing the estimator.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration that lists the command-line options that are available
|
double |
logDensity(double value)
Returns the natural logarithm of the density estimate at the given
point.
|
static void |
main(java.lang.String[] args)
Main method, used for testing this class.
|
java.lang.String |
maxNumComponentsToolTipText()
The tool tip for this property.
|
java.lang.String |
numBootstrapRunsToolTipText()
The tool tip for this property.
|
java.lang.String |
numComponentsToolTipText()
The tool tip for this property.
|
double[][] |
predictIntervals(double conf)
Returns the interval for the given confidence value.
|
double |
predictQuantile(double percentage)
Returns the quantile for the given percentage.
|
double[][] |
resampleWithWeights(java.util.Random random,
boolean[] sampled)
Creates a new dataset of the same size using random sampling with
replacement according to the given weight vector.
|
java.lang.String |
seedTipText()
Returns the tip text for this property
|
void |
setMaxNumComponents(int maxNumComponents)
Sets the number of components to use.
|
void |
setNumBootstrapRuns(int numBootstrapRuns)
Sets the number of Bootstrap runs.
|
void |
setNumComponents(int numComponents)
Sets the number of components to use.
|
void |
setOptions(java.lang.String[] options)
Sets options based on the given array of strings.
|
void |
setSeed(int seed)
Set the seed for random number generation.
|
void |
setUseNormalizedEntropy(boolean useNormalizedEntropy) |
java.lang.String |
toString()
Returns textual description of this estimator.
|
protected void |
updateModel()
Updates the model based on the current data.
|
protected double[] m_Values
protected double[] m_Weights
protected int m_NumValues
protected UnivariateMixtureEstimator.MM m_MixtureModel
protected int m_NumComponents
protected int m_MaxNumComponents
protected int m_Seed
protected int m_NumBootstrapRuns
protected int m_NumIntervals
protected boolean m_UseNormalizedEntropy
protected boolean m_Debug
protected java.util.Random m_Random
public java.lang.String globalInfo()
public boolean getUseNormalizedEntropy()
public void setUseNormalizedEntropy(boolean useNormalizedEntropy)
useNormalizedEntropy - whether to use normalized entropypublic java.lang.String numBootstrapRunsToolTipText()
public int getNumBootstrapRuns()
public void setNumBootstrapRuns(int numBootstrapRuns)
mnumBootstrapRuns - the number of Bootstrap runspublic java.lang.String numComponentsToolTipText()
public int getNumComponents()
public void setNumComponents(int numComponents)
m_NumComponents - the m_NumComponents to setpublic java.lang.String seedTipText()
public void setSeed(int seed)
seed - the seedpublic int getSeed()
public java.lang.String maxNumComponentsToolTipText()
public int getMaxNumComponents()
public void setMaxNumComponents(int maxNumComponents)
maxNumComponents - the maximum number of components to evaluatepublic void addValue(double value,
double weight)
addValue in interface UnivariateDensityEstimatoraddValue in interface UnivariateIntervalEstimatoraddValue in interface UnivariateQuantileEstimatorvalue - the value to addweight - the weight of the valuepublic UnivariateMixtureEstimator.MM buildModel(int K, double[] values, double[] weights)
public double[][] resampleWithWeights(java.util.Random random,
boolean[] sampled)
protected int findNumComponentsUsingBootStrap()
protected double entropy(UnivariateMixtureEstimator.MM mixtureModel)
protected UnivariateMixtureEstimator.MM findModelUsingNormalizedEntropy()
protected void updateModel()
public double[][] predictIntervals(double conf)
predictIntervals in interface UnivariateIntervalEstimatorconf - the confidence value in the interval [0, 1]public double predictQuantile(double percentage)
predictQuantile in interface UnivariateQuantileEstimatorpercentage - the percentagepublic double logDensity(double value)
logDensity in interface UnivariateDensityEstimatorvalue - the value at which to evaluatepublic java.lang.String toString()
toString in class java.lang.Objectpublic java.util.Enumeration<Option> listOptions()
listOptions in interface OptionHandlerpublic void setOptions(java.lang.String[] options)
throws java.lang.Exception
setOptions in interface OptionHandleroptions - the list of options to parsejava.lang.Exception - if an option is not supportedpublic java.lang.String[] getOptions()
getOptions in interface OptionHandlerpublic java.lang.String getRevision()
getRevision in interface RevisionHandlerpublic static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception