Weighted choice


Version: 1.0
Category:
Scripts
Python
Requirements:
Seller:
Price:
-
System:
Rating:
4.5
License:

Description - Weighted choice



Just a few lines of code if you are willing to use numpy. Uses FACT that any prob. distr. can be sampled by computing the cumulative distribution, drawing a random number from 0 to 1, and finding the x-value where that number is attained on the cumulative distribution. The searchsorted(..) function performs this search.



More in Python-Weighted choice

Weighted Cumulative Distribution Value Where That