2

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 ?

AnonymousMe
  • 509
  • 1
  • 5
  • 18
  • Yes, it's a [Discrete distribution](https://en.wikipedia.org/wiki/Probability_distribution#Discrete_probability_distribution) – sascha Jul 25 '20 at 09:20
  • that's exactly what it means, yes. if you have `a` at `0.9` and `b` at `0.1`, then `a` is likely to be chosen 9 times more often than `b`. – Pac0 Jul 25 '20 at 09:30

1 Answers1

0

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).

Aramakus
  • 1,910
  • 2
  • 11
  • 22