n=10;
m=5;
x=0;
for i=1:n,
  x=x+rand(1,1,'normal');
  y(i)=x+rand(1,1,'normal');
end,

for j=1:m
  ksi(j)=0;
end,

for i=1:n,
  for j=1:m,
    ksichapeau(j)=ksi(j)+rand(1,1,'normal');
  end,
  s=0;
  for j=1:m,
    omega(j)=exp(-(y(i)-ksichapeau(j))*(y(i)-ksichapeau(j))/2);
    s=s+omega(j);
  end,
  for j=1:m,
    omegap(j)=omega(j)/s;
  end,
  for j=1:m,
    u=rand(1,1,'uniform');
    b=0;
    s=0;
    k=0;
    while (b==0)
      k=k+1;
      s=s+omegap(k);
      if s>u then b=1;
      end,
    end,
    ksi(j)=ksichapeau(k);
  end,
end,












