Commit 474f7fad authored by Sylvain Calinon's avatar Sylvain Calinon

GMR.m added

parent cb57746d
function [expData, expSigma, H] = GMR(model, DataIn, in, out)
%Gaussian mixture regression (GMR)
%Sylvain Calinon, Danilo Bruno, 2014
nbData = size(DataIn,2);
nbVarOut = length(out);
MuTmp = zeros(nbVarOut,model.nbStates);
expData = zeros(nbVarOut,nbData);
expSigma = zeros(nbVarOut,nbVarOut,nbData);
for t=1:nbData
%Compute activation weight
for i=1:model.nbStates
H(i,t) = model.Priors(i) * gaussPDF(DataIn(:,t), model.Mu(in,i), model.Sigma(in,in,i));
H(:,t) = H(:,t)/sum(H(:,t));
%Compute expected conditional means
for i=1:model.nbStates
MuTmp(:,i) = model.Mu(out,i) + model.Sigma(out,in,i)/model.Sigma(in,in,i) * (DataIn(:,t)-model.Mu(in,i));
expData(:,t) = expData(:,t) + H(i,t) * MuTmp(:,i);
%Compute expected conditional covariances
for i=1:model.nbStates
SigmaTmp = model.Sigma(out,out,i) - model.Sigma(out,in,i)/model.Sigma(in,in,i) * model.Sigma(in,out,i);
expSigma(:,:,t) = expSigma(:,:,t) + H(i,t) * (SigmaTmp + MuTmp(:,i)*MuTmp(:,i)');
for j=1:model.nbStates
expSigma(:,:,t) = expSigma(:,:,t) - H(i,t)*H(j,t) * (MuTmp(:,i)*MuTmp(:,j)');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment