lua-users home
lua-l archive

Re: random toss of discrete values with (integer) probability distribution

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thank you for your nice replies.
As advised by all, I'll build a list of partial sums (actually, I did it since I need to first traverse the list of probabilities to get the total sum, before tossing). Sorting probabilities or binary search to accelerate determination of final result is probably too much work in the present use case, due to a very small count of possibilities (typically ~ 10). However, I'll keep these ideas aside, thank you again.
Denis

AltStyle によって変換されたページ (->オリジナル) /