0

I was hoping to know if there is a command in numpy of scipy to pick an element of a data from a discrete random distribution. i.e.,

For example I have a discrete distribution x = (0.5, 0.3, 0.2) and I want to sample from y = (1, 2, 3)...

>>> sample(x, y)
2
>>> sample(x, y)
3
>>> sample(x, y)
3
>>> sample(x, y)
1

Hope my question is clear. Thanks.

Nikki Mino
  • 309
  • 1
  • 2
  • 12
  • What do you mean by "sample"? – user Jan 30 '15 at 09:07
  • Thank you for your reply. I updated the question but what I was hoping to do is to pick an element of an array data based on a discrete distribution stored in an array with the same dimension as the data. – Nikki Mino Jan 30 '15 at 09:14
  • Is each element of x the probability that the corresponding element of y should be selected? – nekomatic Jan 30 '15 at 09:15
  • Yes it is...I was thinking of placing them in a dict and trying to create a function for it but I was wondering if it exists in numpy or scipy already...Thanks. – Nikki Mino Jan 30 '15 at 09:20
  • possible duplicate of [Generate random numbers with a given (numerical) distribution](http://stackoverflow.com/questions/4265988/generate-random-numbers-with-a-given-numerical-distribution) – user Jan 30 '15 at 09:24

0 Answers0