productTPGMM.m 651 Bytes
Newer Older
1 2
function [Mu, Sigma] = productTPGMM(model, p)
% Sylvain Calinon, Leonel Rozo, 2014
3 4 5 6
% 
% Compute the product of Gaussians for a task-parametrized model where the
% set of parameters are stored in the variable 'p'. 

7 8
% TP-GMM products 
for i = 1:model.nbStates
9 10 11 12 13 14 15 16 17 18 19 20
  % Reallocating  
  SigmaTmp = zeros(model.nbVar);
  MuTmp = zeros(model.nbVar,1);
  % Product of Gaussians
  for m = 1 : model.nbFrames 
    MuP = p(m).A * model.Mu(:,m,i) + p(m).b; 
    SigmaP = p(m).A * model.Sigma(:,:,m,i) * p(m).A'; 
    SigmaTmp = SigmaTmp + inv(SigmaP);
    MuTmp = MuTmp + SigmaP\MuP; 
  end
  Sigma(:,:,i) = inv(SigmaTmp);
  Mu(:,i) = Sigma(:,:,i) * MuTmp;    
21
end