简体   繁体   中英

Probability distribution in np.random.choice

The numpy function np.random.choice takes in an optional parameter called 'p' that denotes the probability distribution of the values it is sampling. So, my question is, even though the function generates random values, do values that have higher probability more likely to be sampled? Meaning, does it randomly choose a value from a subset of " Most probable values "?

Am I right in perceiving it that way? Or can someone please correct my assumption?

It is an optional array of probabilities p with which respective elements of sampled array A are sampled. So A and p should have the same number of elements and all elements of p should add up to 1 (as all discrete probabilities should).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM