JWS C Library
C language utility library
mmm.c File Reference

Multinomial mixture model and parameter fitting using EM. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <inttypes.h>
#include "jwsc/base/limits.h"
#include "jwsc/vector/vector.h"
#include "jwsc/vector/vector_math.h"
#include "jwsc/matrix/matrix.h"
#include "jwsc/matrix/matrix_math.h"
#include "jwsc/matblock/matblock.h"
#include "jwsc/prob/mv_pmf.h"
#include "jwsc/stat/stat.h"
#include "jwsc/stat/kmeans.h"
#include "jwsc/stat/mmm.h"
Include dependency graph for mmm.c:

Go to the source code of this file.

Functions

static void mmm_e_step_d (const Matblock_d *mu, const Vector_d *pi, Matrix_d *gamma, const Matblock_u32 *x)
 E-step in the EM algorithm.
static void mmm_m_step_d (Matblock_d *mu, Vector_d *pi, const Matrix_d *gamma, const Matblock_u32 *x)
 M-step in the EM algorithm.
double mmm_log_likelihood_d (const Matblock_d *mu, const Vector_d *pi, const Matblock_u32 *x)
 Computes the double precision multinomial mixture model log-likelihood.
void mmm_kmeans_init_d (Matblock_d **mu_out, Vector_d **pi_out, const Matblock_u32 *x, uint32_t K)
 Initializes the double precision multinomial mixture model using the kmeans clustering algorithm.
void train_mmm_d (Matblock_d **mu_out, Vector_d **pi_out, Matrix_d **gamma_out, const Matblock_u32 *x, uint32_t K)
 Trains a double precision multinomial mixture model.

Detailed Description

Multinomial mixture model and parameter fitting using EM.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

The multinomials are represented as a set of binary variables.

Definition in file mmm.c.


Function Documentation

static void mmm_e_step_d ( const Matblock_d mu,
const Vector_d pi,
Matrix_d gamma,
const Matblock_u32 x 
) [static]

E-step in the EM algorithm.

Definition at line 70 of file mmm.c.

static void mmm_m_step_d ( Matblock_d mu,
Vector_d pi,
const Matrix_d gamma,
const Matblock_u32 x 
) [static]

M-step in the EM algorithm.

Definition at line 135 of file mmm.c.

double mmm_log_likelihood_d ( const Matblock_d mu,
const Vector_d pi,
const Matblock_u32 x 
)

Computes the double precision multinomial mixture model log-likelihood.

Parameters:
muMultivariate multinomial means.
piMixture component weights.
xBinary data.

Definition at line 195 of file mmm.c.

void mmm_kmeans_init_d ( Matblock_d **  mu_out,
Vector_d **  pi_out,
const Matblock_u32 x,
uint32_t  K 
)

Initializes the double precision multinomial mixture model 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 1 sample.

Parameters:
mu_outMultivariate multinomial parameters.
pi_outMixture component weights.
xData.
KNumber of mixture components.

Definition at line 268 of file mmm.c.

void train_mmm_d ( Matblock_d **  mu_out,
Vector_d **  pi_out,
Matrix_d **  gamma_out,
const Matblock_u32 x,
uint32_t  K 
)

Trains a double precision multinomial mixture model.

If *mu_out and *pi_out are not initialized, mmm_kmeans_init_d() is used to do so.

Parameters:
mu_outResult parameter. Parameters for mixture components.
pi_outResult parameter. Mixture component weights.
gamma_outOptional result parameter. Responsibilities of each mixture component per sample. If NULL, the variable is ignored.
xData to train the MMM with.
KNumber of mixture components.

Definition at line 353 of file mmm.c.