Package com.irurueta.numerical
Class HistogramMaximumLikelihoodEstimator
java.lang.Object
com.irurueta.numerical.MaximumLikelihoodEstimator
com.irurueta.numerical.HistogramMaximumLikelihoodEstimator
Class to estimate the most likely value from a series of samples assumed to
be normally distributed.
This implementation will compute a histogram of the probability distribution
function of all the provided samples.
The probability distribution function is computed by aggregating all the
samples as a series of Gaussian functions with a small sigma and centered at
the exact value of the sample.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate double[]
Number of samples contained on each bin.static final int
Default number of bins to be used on the histogram.static final double
Value to be considered as the machine precision.private double[]
Array containing the Gaussian values corresponding to each bin for a single sample.static final int
Minimum number of bins allowed on the histogram.private int
Number of bins to be used on the histogram.Fields inherited from class com.irurueta.numerical.MaximumLikelihoodEstimator
areMinMaxAvailable, DEFAULT_GAUSSIAN_SIGMA, DEFAULT_METHOD, gaussianSigma, inputData, locked, maxValue, MIN_GAUSSIAN_SIGMA, minValue
-
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor.HistogramMaximumLikelihoodEstimator
(double[] inputData, double gaussianSigma, int numberOfBins) Constructor.HistogramMaximumLikelihoodEstimator
(double minValue, double maxValue, double[] inputData, double gaussianSigma, int numberOfBins) Constructor.HistogramMaximumLikelihoodEstimator
(double gaussianSigma, int numberOfBins) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
computeGaussian
(double[] gaussian, double centerPos) Internal method to compute values of Gaussian vector assumed to be centered at provided value.double
estimate()
Starts the estimation of the most likely value contained within provided input data array.Returns method to be used for maximum likelihood estimation, which for this class is MaximumLikelihoodEstimatorMethod.int
Returns number of bins to be used on the histogram.private void
internalSetNumberOfBins
(int numberOfBins) Internal method to set number of bins to be used on the histogram.void
setNumberOfBins
(int numberOfBins) Sets number of bins to be used on the histogram.Methods inherited from class com.irurueta.numerical.MaximumLikelihoodEstimator
areMinMaxValuesAvailable, computeMinMaxValues, create, create, create, create, create, create, create, create, create, getGaussianSigma, getInputData, getMaxValue, getMinValue, isInputDataAvailable, isLocked, isReady, setGaussianSigma, setInputData, setInputData, setMinMaxValues
-
Field Details
-
DEFAULT_NUMBER_OF_BINS
public static final int DEFAULT_NUMBER_OF_BINSDefault number of bins to be used on the histogram.- See Also:
-
MIN_NUMBER_OF_BINS
public static final int MIN_NUMBER_OF_BINSMinimum number of bins allowed on the histogram.- See Also:
-
EPS
public static final double EPSValue to be considered as the machine precision.- See Also:
-
numberOfBins
private int numberOfBinsNumber of bins to be used on the histogram. The larger the value the more precise results will be but more data will be needed to obtain statistically meaningful data so that enough samples are present on each bin. -
bins
private double[] binsNumber of samples contained on each bin. The number of samples is not an integer because the Gaussians of each sample will only have a value equal to one on their respective centers, but at other locations, only the fractional part is added to each bin. Using Gaussians on each sample behave as an interpolation of the location of each sample around a certain value. -
gaussian
private double[] gaussianArray containing the Gaussian values corresponding to each bin for a single sample. The values of each array are updated for each sample and aggregated to the values of the bins array.
-
-
Constructor Details
-
HistogramMaximumLikelihoodEstimator
public HistogramMaximumLikelihoodEstimator()Empty constructor. -
HistogramMaximumLikelihoodEstimator
public HistogramMaximumLikelihoodEstimator(double gaussianSigma, int numberOfBins) Constructor.- Parameters:
gaussianSigma
- Gaussian sigma to be used on each sample.numberOfBins
- Number of bins to be used on the histogram.- Throws:
IllegalArgumentException
- Raised if provided Gaussian sigma is negative or zero, or if provided number of bins is smaller than the minimum allowed number of bins.
-
HistogramMaximumLikelihoodEstimator
public HistogramMaximumLikelihoodEstimator(double[] inputData, double gaussianSigma, int numberOfBins) Constructor.- Parameters:
inputData
- Array containing input data where most likely value must be estimated from.gaussianSigma
- Gaussian sigma to be used on each sample.numberOfBins
- Number of bins to be used on the histogram.- Throws:
IllegalArgumentException
- Raised if provided Gaussian sigma is negative or zero, or if provided number of bins is smaller than the minimum allowed number of bins.
-
HistogramMaximumLikelihoodEstimator
public HistogramMaximumLikelihoodEstimator(double minValue, double maxValue, double[] inputData, double gaussianSigma, int numberOfBins) Constructor.- Parameters:
minValue
- Minimum value assumed to be contained within input data array.maxValue
- Maximum value assumed to be contained within input data array.inputData
- Array containing input data where most likely value must be estimated from.gaussianSigma
- Gaussian sigma to be used on each sample.numberOfBins
- Number of bins to be used on the histogram.- Throws:
IllegalArgumentException
- Raised if provided Gaussian sigma is negative or zero, or if provided number of bins is smaller than the minimum allowed number of bins or if minValue < maxValue.
-
-
Method Details
-
getMethod
Returns method to be used for maximum likelihood estimation, which for this class is MaximumLikelihoodEstimatorMethod. HISTOGRAM_MAXIMUM_LIKELIHOOD_ESTIMATOR.- Specified by:
getMethod
in classMaximumLikelihoodEstimator
- Returns:
- Method for maximum likelihood estimation.
-
getNumberOfBins
public int getNumberOfBins()Returns number of bins to be used on the histogram. The larger the value the more precise results will be but more data will be needed to obtain statistically meaningful data so that enough samples are present on each bin.- Returns:
- Number of bins to be used on the histogram.
-
setNumberOfBins
Sets number of bins to be used on the histogram. The larger the provided value being set the more precise results will be but more data will be needed to obtain statistically meaningful data so that enough samples are present on each bin.- Parameters:
numberOfBins
- Number of bins to be used on the histogram.- Throws:
LockedException
- Exception raised if this instance is locked. This method can only be executed when computations finish and this instance becomes unlocked.IllegalArgumentException
- Raised if provided value is lower than the allowed minimum.
-
estimate
Starts the estimation of the most likely value contained within provided input data array.- Specified by:
estimate
in classMaximumLikelihoodEstimator
- Returns:
- The most likely value.
- Throws:
LockedException
- Exception raised if this instance is locked. This method can only be executed when computations finish and this instance becomes unlocked.NotReadyException
- Exception raised if this instance is not yet ready.- See Also:
-
computeGaussian
protected void computeGaussian(double[] gaussian, double centerPos) Internal method to compute values of Gaussian vector assumed to be centered at provided value. Gaussian values are stored in provided array so that array can be reused.- Parameters:
gaussian
- Array containing Gaussian valuescenterPos
- Value where Gaussian is centered
-
internalSetNumberOfBins
private void internalSetNumberOfBins(int numberOfBins) Internal method to set number of bins to be used on the histogram. The larger the value being set the more precise results will be but more data will be needed to obtain statistically meaningful data so that enough samples are present on each bin.- Parameters:
numberOfBins
- Number of bins to be used on the histogram.- Throws:
IllegalArgumentException
- Raised if provided value is lower than the allowed minimum.
-