jemnotesversion 2 / featuring this entry or see all/search

Jul 31
Sampling from a discrete distribution, where p is a vector of probabilities:
min(find(rand() < cumsum(p)))