public class MultivariateNormalMixtureExpectationMaximization
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
MultivariateNormalMixtureExpectationMaximization.DataRow
Class used for sorting user-supplied data.
|
Modifier and Type | Field and Description |
---|---|
private double[][] |
data
The data to fit.
|
private static int |
DEFAULT_MAX_ITERATIONS
Default maximum number of iterations allowed per fitting process.
|
private static double |
DEFAULT_THRESHOLD
Default convergence threshold for fitting.
|
private MixtureMultivariateNormalDistribution |
fittedModel
The model fit against the data.
|
private double |
logLikelihood
The log likelihood of the data given the fitted model.
|
Constructor and Description |
---|
MultivariateNormalMixtureExpectationMaximization(double[][] data)
Creates an object to fit a multivariate normal mixture model to data.
|
Modifier and Type | Method and Description |
---|---|
static MixtureMultivariateNormalDistribution |
estimate(double[][] data,
int numComponents)
Helper method to create a multivariate normal mixture model which can be
used to initialize
fit(MixtureMultivariateNormalDistribution) . |
void |
fit(MixtureMultivariateNormalDistribution initialMixture)
Fit a mixture model to the data supplied to the constructor.
|
void |
fit(MixtureMultivariateNormalDistribution initialMixture,
int maxIterations,
double threshold)
Fit a mixture model to the data supplied to the constructor.
|
MixtureMultivariateNormalDistribution |
getFittedModel()
Gets the fitted model.
|
double |
getLogLikelihood()
Gets the log likelihood of the data under the fitted model.
|
private static final int DEFAULT_MAX_ITERATIONS
private static final double DEFAULT_THRESHOLD
private final double[][] data
private MixtureMultivariateNormalDistribution fittedModel
private double logLikelihood
public MultivariateNormalMixtureExpectationMaximization(double[][] data) throws NotStrictlyPositiveException, DimensionMismatchException, NumberIsTooSmallException
data
- Data to use in fitting procedureNotStrictlyPositiveException
- if data has no rowsDimensionMismatchException
- if rows of data have different numbers
of columnsNumberIsTooSmallException
- if the number of columns in the data is
less than 2public void fit(MixtureMultivariateNormalDistribution initialMixture, int maxIterations, double threshold) throws SingularMatrixException, NotStrictlyPositiveException, DimensionMismatchException
initialMixture
- Model containing initial values of weights and
multivariate normalsmaxIterations
- Maximum iterations allowed for fitthreshold
- Convergence threshold computed as difference in
logLikelihoods between successive iterationsSingularMatrixException
- if any component's covariance matrix is
singular during fittingNotStrictlyPositiveException
- if numComponents is less than one
or threshold is less than Double.MIN_VALUEDimensionMismatchException
- if initialMixture mean vector and data
number of columns are not equalpublic void fit(MixtureMultivariateNormalDistribution initialMixture) throws SingularMatrixException, NotStrictlyPositiveException
initialMixture
- Model containing initial values of weights and
multivariate normalsSingularMatrixException
- if any component's covariance matrix is
singular during fittingNotStrictlyPositiveException
- if numComponents is less than one or
threshold is less than Double.MIN_VALUEpublic static MixtureMultivariateNormalDistribution estimate(double[][] data, int numComponents) throws NotStrictlyPositiveException, DimensionMismatchException
fit(MixtureMultivariateNormalDistribution)
.
This method uses the data supplied to the constructor to try to determine
a good mixture model at which to start the fit, but it is not guaranteed
to supply a model which will find the optimal solution or even converge.data
- Data to estimate distributionnumComponents
- Number of components for estimated mixtureNumberIsTooLargeException
- if numComponents
is greater
than the number of data rows.NumberIsTooSmallException
- if numComponents < 2
.NotStrictlyPositiveException
- if data has less than 2 rowsDimensionMismatchException
- if rows of data have different numbers
of columnspublic double getLogLikelihood()
public MixtureMultivariateNormalDistribution getFittedModel()
null
if no fit has been performed yet.Copyright (c) 2003-2013 Apache Software Foundation