function x=multrnd(w)
% generates one observation from a multinomial with weights proportional to vector w
p=[0 cumsum(w/sum(w))];
x=sum(rand>p);
