Commit 0f1c56b4 authored by Sylvain Calinon's avatar Sylvain Calinon

Modification of estimate of covariance in GMR

parent 46e83db2
...@@ -40,6 +40,7 @@ for i=1:model.nbStates ...@@ -40,6 +40,7 @@ for i=1:model.nbStates
end end
%GMR %GMR
MuTmp = zeros(nbVarOut,model.nbStates);
for t=1:nbData for t=1:nbData
%Compute activation weight %Compute activation weight
for i=1:model.nbStates for i=1:model.nbStates
...@@ -48,13 +49,20 @@ for t=1:nbData ...@@ -48,13 +49,20 @@ for t=1:nbData
r.H(:,t) = r.H(:,t)/sum(r.H(:,t)); r.H(:,t) = r.H(:,t)/sum(r.H(:,t));
%Evaluate the current target %Evaluate the current target
currTar = zeros(nbVarOut,1); currTar = zeros(nbVarOut,1);
currSigma = zeros(nbVarOut,nbVarOut); currSigma = zeros(nbVarOut,nbVarOut);
for i=1:model.nbStates %Compute expected conditional means
tarTmp = r.Mu(out,i) + r.Sigma(out,in,i)/r.Sigma(in,in,i) * (DataIn(:,t)-r.Mu(in,i)); for i=1:model.nbStates
SigmaTmp = r.Sigma(out,out,i) - r.Sigma(out,in,i)/r.Sigma(in,in,i) * r.Sigma(in,out,i); MuTmp(:,i) = r.Mu(out,i) + r.Sigma(out,in,i)/r.Sigma(in,in,i) * (DataIn(:,t)-r.Mu(in,i));
currTar = currTar + r.H(i,t) * tarTmp; currTar = currTar + r.H(i,t) * MuTmp(:,i);
currSigma = currSigma + r.H(i,t) * SigmaTmp; %r.H(i,t)^2 end
end %Compute expected conditional covariances
for i=1:model.nbStates
SigmaTmp = r.Sigma(out,out,i) - r.Sigma(out,in,i)/r.Sigma(in,in,i) * r.Sigma(in,out,i);
currSigma = currSigma + r.H(i,t) * (SigmaTmp + MuTmp(:,i)*MuTmp(:,i)');
for j=1:model.nbStates
currSigma = currSigma - r.H(i,t)*r.H(j,t) * (MuTmp(:,i)*MuTmp(:,j)');
end
end
r.currTar(:,t) = currTar; r.currTar(:,t) = currTar;
r.currSigma(:,:,t) = currSigma; r.currSigma(:,:,t) = currSigma;
end end
......
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