GMMParameterEstimation.jl Documentation
GMMParameterEstimation.jl is a package for estimating the parameters of Gaussian k mixture models using the method of moments. It works for general k with known mixing coefficients, and for k=2,3,4 for unknown mixing coefficients.
Parameter estimation
The main functionality of this package stems from
GMMParameterEstimation.estimate_parameters
— Functionestimate_parameters(d::Integer, k::Integer, sample::Array{Float64}, diagonal::Bool)
Compute an estimate for the parameters of a d
-dimensional Gaussian k
-mixture model from a sample.
If diagonal
is true, the covariance matrices are assumed to be diagonal. If w
is provided it is taken as the mixing coefficients, otherwise those are computed as well. The sample should be a d x sample-size array.
estimate_parameters(d::Integer, k::Integer, sample::Array{Float64}, diagonal::Bool, w::Array{Float64})
Compute an estimate for the parameters of a d
-dimensional Gaussian k
-mixture model from a sample.
If diagonal
is true, the covariance matrices are assumed to be diagonal. If w
is provided it is taken as the mixing coefficients, otherwise those are computed as well. The sample should be a d x sample-size array.
For example, the following code snippet will generate a 3D 2-mixture, take a sample, compute the necessary moments, and then return an estimate of the parameters using the method of moments.
using GMMParameterEstimation
d = 3
k = 2
diagonal = true
num_samples = 10^4
w, true_means, true_covariances = generateGaussians(d, k, diagonal)
sample = getSample(num_samples, w, true_means, true_covariances)
first_moms, diagonal_moms, off_diagonals = sampleMoments(sample, k)
pass, (mixing_coefficients, means, covariances) = estimate_parameters(d, k, first_moms, diagonal_moms, off_diagonals, diagonal)
Generate and sample from Gaussian Mixture Models
GMMParameterEstimation.makeCovarianceMatrix
— FunctionmakeCovarianceMatrix(d::Integer, diagonal::Bool)
Generate random d
xd
covariance matrix.
If diagonal
==true, returns a diagonal covariance matrix.
GMMParameterEstimation.generateGaussians
— FunctiongenerateGaussians(d::Integer, k::Integer, diagonal::Bool)
Generate means and covariances for k
Gaussians with dimension d
.
diagonal
should be true for spherical case, and false for dense covariance matrices.
GMMParameterEstimation.getSample
— FunctiongetSample(numb::Integer, w::Vector{Float64}, means::Matrix{Float64}, covariances::Array{Float64, 3})
Generate a Gaussian mixture model sample with numb
entries, mixing coefficients w
, means means
, and covariances covariances
.
Missing docstring for sampleMoments
. Check Documenter's build log for details.
Missing docstring for perfectMoments
. Check Documenter's build log for details.
Build the polynomial systems
GMMParameterEstimation.build1DSystem
— Functionbuild1DSystem(k::Integer, m::Integer)
Build the polynomial system for a mixture of 1D Gaussians where 'm' is the highest desired moment.
If a
is given, use a
as the mixing coefficients, otherwise leave them as unknowns.
build1DSystem(k::Integer, m::Integer, a::Union{Vector{Float64}, Vector{Variable}})
Build the polynomial system for a mixture of 1D Gaussians where 'm' is the highest desired moment.
If a
is given, use a
as the mixing coefficients, otherwise leave them as unknowns.
GMMParameterEstimation.selectSol
— FunctionselectSol(k::Integer, solution::Result, polynomial::Expression, moment::Number)
Select a k
mixture solution from solution
accounting for polynomial
and moment
.
Sort out a k
mixture statistically significant solutions from solution
, and return the one closest to moment
when polynomial
is evaluated at those values.
GMMParameterEstimation.tensorPower
— FunctiontensorPower(tensor, power::Integer)
Compute the power
tensor power of tensor
.
GMMParameterEstimation.convert_indexing
— Functionconvert_indexing(moment_i, d)
Convert the d
dimensional multivariate moment_i
index to the corresponding tensor moment index.
GMMParameterEstimation.mixedMomentSystem
— FunctionmixedMomentSystem(d, k, mixing, ms, vs)
Build a linear system for finding the off-diagonal covariances entries.
For a d
dimensional Gaussian k
-mixture model with mixing coefficients mixing
, means ms
, and covariances vs
where the diagonal entries have been filled in and the off diagonals are variables.
Index
GMMParameterEstimation.build1DSystem
GMMParameterEstimation.convert_indexing
GMMParameterEstimation.estimate_parameters
GMMParameterEstimation.generateGaussians
GMMParameterEstimation.getSample
GMMParameterEstimation.makeCovarianceMatrix
GMMParameterEstimation.mixedMomentSystem
GMMParameterEstimation.selectSol
GMMParameterEstimation.tensorPower