0

So in my python script, I have a list of probabilities from 0 to 1. It is my intention to generate a list of events that either happen or don't happen (i.e. TRUE or FALSE) that is proportional to these probabilities.

Here is a short sample of my table of probabilities

[0.6297872340425532
0.28453608247422685
0.4
0.04878048780487805
0.4225352112676056
0.175609756097561
0.14222222222222222
.....]

And ideally, my script would iterate through the list of probabilities and either generate TRUE or FALSE based on each of them. However, when I run the script multiple times, I don't want to get the same results more than once. Essentially, it should be a weighted random choice, however I don't believe the random module has this functionality. Are there any that I could use for my problem?

  • I'm not sure I understand why you think the `random` module won't work for your needs. It seeds itself randomly, by default, so you'd only get the same results only in extremely unlikely situations (e.g. when your OS's random number source has been compromised, or if you run the script multiple times in the same second). – Blckknght Feb 07 '19 at 02:39
  • Take a look at https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.choice.html#numpy.random.choice – Charles Feb 07 '19 at 02:39

0 Answers0