org.openimaj.math.statistics.distribution

Class MixtureOfGaussians

• Field Summary

Fields
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 Summary

Constructors
Constructor and Description
MixtureOfGaussians(MultivariateGaussian[] gaussians, double[] weights)
Construct the mixture with the given gaussians and weights
• Method Summary

All Methods
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.
• Constructor Detail

• MixtureOfGaussians

public MixtureOfGaussians(MultivariateGaussian[] gaussians,
double[] weights)
Construct the mixture with the given gaussians and weights
Parameters:
gaussians - the gaussians
weights - the weights
• Method Detail

• sample

public double[] sample(Random rng)
Description copied from interface: MultivariateDistribution
Sample the distribution. the number of samples to draw
Parameters:
rng - the random number generator
Returns:
a list of sample vectors from this distribution
• estimateLogProbability

public double[] estimateLogProbability(double[][] samples)
Get the probability for a given points in space relative to the PDF represented by the gaussian mixture.
Parameters:
samples - the points
Returns:
the probability
• logProbability

public static double[][] logProbability(double[][] x,
MultivariateGaussian[] gaussians)
Compute the log probability of the given data points belonging to each of the given gaussians
Parameters:
x - the points
gaussians - the gaussians
Returns:
the log probability of each point belonging to each gaussian distribution
• logProbability

public double[][] logProbability(double[][] x)
Compute the log probability of the given data points belonging to each of the gaussians
Parameters:
x - the points
Returns:
the log probability of each point belonging to each gaussian distribution
• predictLogPosterior

public 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.
Parameters:
sample - the sample
Returns:
the log-probability for each gaussian
• predictLogPosterior

public 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.
Parameters:
samples - the samples
Returns:
the log-probability for each gaussian
• scoreSamples

public 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.
Parameters:
samples - the samples
Returns:
a pair of (log probabilities, log posterior probabilities)
• getWeights

public double[] getWeights()
Get the mixture weights for each gaussian.
Returns:
the weights
• estimateProbability

public double estimateProbability(double[] sample)
Description copied from interface: MultivariateDistribution
Get the probability for a given point in space relative to the PDF represented by this distribution.
Parameters:
sample - the point
Returns:
the probability
• predict

public int predict(double[] data)
Predict the class (the index of the most-probable gaussian) to which the given data point belongs.
Parameters:
data - the data point
Returns:
the class index