public class MixtureOfGaussians extends AbstractMultivariateDistribution
GaussianMixtureModelEM
class for example).Modifier and Type | Field and Description |
---|---|
MultivariateGaussian[] |
gaussians
The individual gaussians
|
static double |
MIN_COVAR_RECONDITION
Amount to add to the diagonal of the covariance matrix if it's
ill-conditioned.
|
double[] |
weights
The weight of each gaussian
|
Constructor and Description |
---|
MixtureOfGaussians(MultivariateGaussian[] gaussians,
double[] weights)
Construct the mixture with the given gaussians and weights
|
Modifier and Type | Method and Description |
---|---|
protected double[][] |
computeWeightedLogProb(double[][] samples) |
double |
estimateLogProbability(double[] sample)
Get the log probability for a given point in space relative to the PDF
represented by this distribution.
|
double[] |
estimateLogProbability(double[][] samples)
Get the probability for a given points in space relative to the PDF
represented by the gaussian mixture.
|
double |
estimateProbability(double[] sample)
Get the probability for a given point in space relative to the PDF
represented by this distribution.
|
MultivariateGaussian[] |
getGaussians()
Get the gaussians that make up the mixture
|
double[] |
getWeights()
Get the mixture weights for each gaussian.
|
double[][] |
logProbability(double[][] x)
Compute the log probability of the given data points belonging to each of
the gaussians
|
static double[][] |
logProbability(double[][] x,
MultivariateGaussian[] gaussians)
Compute the log probability of the given data points belonging to each of
the given gaussians
|
int |
predict(double[] data)
Predict the class (the index of the most-probable gaussian) to which the
given data point belongs.
|
double[] |
predictLogPosterior(double[] sample)
Predict the log-posterior for the given sample; this is the
log-probability of the sample point belonging to each of the gaussians in
the mixture.
|
double[][] |
predictLogPosterior(double[][] samples)
Predict the log-posterior for the given samples; this is the
log-probability of each sample point belonging to each of the gaussians
in the mixture.
|
double[][] |
sample(int n_samples,
Random rng)
Sample the distribution.
|
double[] |
sample(Random rng)
Sample the distribution.
|
IndependentPair<double[],double[][]> |
scoreSamples(double[][] samples)
Compute the posterior distribution of the samples, and the overall log
probability of each sample as belonging to the model.
|
public static final double MIN_COVAR_RECONDITION
public MultivariateGaussian[] gaussians
public double[] weights
public MixtureOfGaussians(MultivariateGaussian[] gaussians, double[] weights)
gaussians
- the gaussiansweights
- the weightspublic double[] sample(Random rng)
MultivariateDistribution
rng
- the random number generatorpublic double[][] sample(int n_samples, Random rng)
MultivariateDistribution
sample
in interface MultivariateDistribution
sample
in class AbstractMultivariateDistribution
n_samples
- the number of samples to drawrng
- the random number generatorpublic double estimateLogProbability(double[] sample)
MultivariateDistribution
estimateLogProbability
in interface MultivariateDistribution
estimateLogProbability
in class AbstractMultivariateDistribution
sample
- the pointpublic double[] estimateLogProbability(double[][] samples)
samples
- the pointspublic static double[][] logProbability(double[][] x, MultivariateGaussian[] gaussians)
x
- the pointsgaussians
- the gaussiansprotected double[][] computeWeightedLogProb(double[][] samples)
public double[][] logProbability(double[][] x)
x
- the pointspublic double[] predictLogPosterior(double[] sample)
sample
- the samplepublic double[][] predictLogPosterior(double[][] samples)
samples
- the samplespublic IndependentPair<double[],double[][]> scoreSamples(double[][] samples)
samples
- the samplespublic MultivariateGaussian[] getGaussians()
public double[] getWeights()
public double estimateProbability(double[] sample)
MultivariateDistribution
sample
- the pointpublic int predict(double[] data)
data
- the data point