Commit 186de044 authored by Frédéric Karamé's avatar Frédéric Karamé
Browse files

fix bugs for sampling in a gaussian-mixture distributions.

parent f7e3ad7b
function State_Particles = importance_sampling(StateMuPost,StateSqrtPPost,StateWeightsPost,numP)
[Xdim,Gsecond] = size(StateMuPost) ;
u = rand(numP,1);
[Nc,comp] = histc(u, cumsum([0; StateWeightsPost]));
State_Particles = zeros(Xdim,numP);
for k=1:Gsecond
idx = bsxfun(@eq,comp,k*ones(size(comp))) ;
State_Particles(:,idx) = StateSqrtPPost(:,:,k)*randn(Xdim,Nc(k));
State_Particles= State_Particles + StateMuPost(:,comp);
Supports Markdown
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