File Exchange

image thumbnail

Gaussian Mixture Model (GMM) - Gaussian Mixture Regression (GMR)

version 1.2.0.0 (39.9 KB) by Sylvain Calinon
Encoding of data in Gaussian Mixture Model and retrieval through Gaussian Mixture Regression

26 Downloads

Updated 24 Jul 2009

View Version History

View License

GMM-GMR is a set of Matlab functions to train a Gaussian Mixture Model (GMM) and retrieve generalized data through Gaussian Mixture Regression (GMR). It allows to encode efficiently any dataset in Gaussian Mixture Model (GMM) through the use of an Expectation-Maximization (EM) iterative learning algorithms. By using this model, Gaussian Mixture Regression (GMR) can then be used to retrieve partial output data by specifying the desired inputs. It then acts as a generalization process that computes conditional probability with respect to partially observed data.

A sample is provided to load a dataset containing several trajectory data [t,x] where t is a temporal value and x is a position in 3D. The joint probability p(t,x) is then encoded in GMM, and GMR is used to retrieve p(x|t), namely the expected position at each time step. This is used to retrieve a smooth generalized version of the trajectories provided.

The source codes are implementations of the algorithms described in the book "Robot Programming by Demonstration: A Probabilistic Approach", EPFL/CRC Press. More information on http://programming-by-demonstration.org/book/

Cite As

Sylvain Calinon (2020). Gaussian Mixture Model (GMM) - Gaussian Mixture Regression (GMR) (https://www.mathworks.com/matlabcentral/fileexchange/19630-gaussian-mixture-model-gmm-gaussian-mixture-regression-gmr), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (24)

Madiha Javeed

Hi, Nice work!
I am getting the problem of Memory limit or Memory Out at the following line:
Sigma_y_tmp2 = repmat(beta_tmp.*beta_tmp, [length(out) length(out) 1 1]) .* repmat(Sigma_y_tmp,[1 1 nbData 1]);

My Data is 3915x70. Can anyone guess what is wrong with it?

Thanks

Liangwu Yan

Huaizu Jiang

Samuele Speranza

Thanks for the code, very good.
I think that in the code of GMR is better change nbData = length(x) with nbData = size(x,2) because if there are less data than the datapoints dimensions the code do not work.

HSN

Thanks for the code.

To eliminate the warning about Matrix singularity, I replace the zero values of calculated probability in 'gaussPDF.m' by realmin value. Because that zero values cause nan in posterior probability p(i|x).

Seungho Jeong

Mohammad Najafi

francesco

Nie Shaoshuai

good!

Dongsheng

Thanks for you code. It is great! But to address my problem, I need every Gaussion function shares exactly the same width. Is that possible or which part I need to amend?

Best
Dongsheng

Bahareh

I'm trying to implement this for my data but at the first stage, I'm getting the following error:
Warning: Matrix is singular, close to singular or badly scaled.
Results may be inaccurate. RCOND = NaN.
> In gaussPDF at 21
In EM at 94
Can you please help me?

Holger

Nice implementation.

Just a tiny little thing: I was wondering why there is no function that computes the output (i.e. the probability) of a learned GMM for a set of data points. I know that it can easily be done by summing the PDFs of all GMM components (using the function gaussPDF(...)) multiplied by their respective prior.
Also, some of the dimensions of the vectors and matrices in the help-text of the function gaussPDF(...) are not correct. It should be:
Mu: D x 1 array
Sigma: D x D array

haifa ben saber

you shoud change your parameters !! but i can't interpret the resualt !!

Oleg

I had such problem also. The reason was that some other kmeans.m (with other order of inputs) overrides original one. In my example it was kmeans from MatlabArsenal. So I have deleted its path from Matlab's directories ("File->Set Path...")

Kamil Wojcicki

Janez Podobnik

If I run demo1, demo2 or demo3 I always get the same error
??? Error using ==> kmeans at 46
Data dimension does not match dimension of centres

Error in ==> EM_init_kmeans at 27
[Data_id, Centers] = kmeans(Data', nbStates);

Error in ==> demo1 at 52
[Priors, Mu, Sigma] = EM_init_kmeans(Data, nbStates);

What I am doing wrong?

Eric Trautmann

This also does not work for 3D data, line 28 of plotGMM explicitly considers only the 2D case since the [cos(t) sin(t)] constrains the result to be a length(t) x 2 matrix:

X = [cos(t) sin(t)] * real(stdev) + repmat(Mu(:,j)',nbDrawingSeg,1);

The documentation appears great, but suggests that this can handle arbitrarily high dimensional cases.

Daniel Goodman

Rifat

I guess nobody tried to plot the GMM for the 1-D data. I am getting "Matrix dimensions must agree" error in plotGMM line 28.

Lesab Lahgab

Excellent!

Christie Smith

There is also a kmeans function in LeSage's toolbox that you need to avoid when trying to use EM_init_kmeans. The demos ran as expected and the code seems pretty well documented.

safri ilias

good

Nicholas Simanjuntak

this is good

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!