JWS C Library
C language utility library
|
Gaussian mixture model and parameter fitting using EM. More...
#include <jwsc/config.h>
#include <stdlib.h>
#include <inttypes.h>
#include "jwsc/vector/vector.h"
#include "jwsc/matrix/matrix.h"
#include "jwsc/matblock/matblock.h"
Go to the source code of this file.
Functions | |
double | gmm_log_likelihood_d (const Matrix_d *mu, const Matblock_d *sigma, const Vector_d *pi, const Matrix_d *x) |
Computes the double precision Gaussian mixture model log-likelihood. | |
void | gmm_kmeans_init_d (Matrix_d **mu_out, Matblock_d **sigma_out, Vector_d **pi_out, const Matrix_d *x, uint32_t K) |
Initializes the double precision Gaussian mixture model means, covariances, and mixture weights using the kmeans clustering algorithm. | |
void | gmm_stats_init_d (Matrix_d **mu_out, Matblock_d **sigma_out, Vector_d **pi_out, const Matrix_d *x, uint32_t K) |
Initializes the double precision Gaussian mixture model means, covariances, and mixture weights with sample statistics. | |
void | train_gmm_d (Matrix_d **mu_out, Matblock_d **sigma_out, Vector_d **pi_out, Matrix_d **gamma_out, const Matrix_d *x, uint32_t K) |
Trains a double precision Gaussian mixture model. |
Gaussian mixture model and parameter fitting using EM.
Definition in file gmm.h.
double gmm_log_likelihood_d | ( | const Matrix_d * | mu, |
const Matblock_d * | sigma, | ||
const Vector_d * | pi, | ||
const Matrix_d * | x | ||
) |
void gmm_kmeans_init_d | ( | Matrix_d ** | mu_out, |
Matblock_d ** | sigma_out, | ||
Vector_d ** | pi_out, | ||
const Matrix_d * | x, | ||
uint32_t | K | ||
) |
Initializes the double precision Gaussian mixture model means, covariances, and mixture weights using the kmeans clustering algorithm.
If one of the arguments is already allocated, it is assumed to be initialized as well.
Minimum cluster membership is 2 samples.
mu_out | Multivariate Gaussian means. |
sigma_out | Multivariate Gaussian Covariance matrices. |
pi_out | Mixture component weights. |
x | Data. |
K | Number of mixture components. |
void gmm_stats_init_d | ( | Matrix_d ** | mu_out, |
Matblock_d ** | sigma_out, | ||
Vector_d ** | pi_out, | ||
const Matrix_d * | x, | ||
uint32_t | K | ||
) |
Initializes the double precision Gaussian mixture model means, covariances, and mixture weights with sample statistics.
All cluster covariance matrices are set to the sample covariance. One mean is set from the sample mean, and the rest are random samples from a Gaussian using the sample mean and covariance matrix.
If one of the arguments is already allocated, it is assumed to be initialized as well.
mu_out | Multivariate Gaussian means. |
sigma_out | Multivariate Gaussian covariance matrices. |
pi_out | Mixture component weights. |
x | Data. |
K | Number of mixture components. |
void train_gmm_d | ( | Matrix_d ** | mu_out, |
Matblock_d ** | sigma_out, | ||
Vector_d ** | pi_out, | ||
Matrix_d ** | gamma_out, | ||
const Matrix_d * | x, | ||
uint32_t | K | ||
) |
Trains a double precision Gaussian mixture model.
If *mu_out, *sigma_out and *pi_out are not initialized, gmm_kmeans_init_d() is used to do so.
mu_out | Result parameter. Means for each mixture component. |
sigma_out | Result parameter. Covariance matrices for each mixture component. |
pi_out | Result parameter. Mixture component weights. |
gamma_out | Optional result parameter. Responsibilities of each mixture component per sample. If NULL, the variable is ignored. |
x | Data to train the GMM with. |
K | Number of mixture components. |