jeudi 17 novembre 2016

Python: selection random number

I'm trying to understand principle of random library's work. I consider some situations: 1) I have value b and it can take the value 0 or 1 with probability 0.5. I know, that I can realize that with

numpy.random.choice(numpy.arange(0, 2), p=[0.5, 0.5])

I want to understand, what steps are executed to choose some value? It separates this segment and gets random value? How does it happen?

2) Or if I have, maybe a list. lst = [1, 4, 7, 3, 254, 6, 2, 7, 3123, 454657, 34, 565, 99] I can you a common way to do that random.choice(lst)) but I want to understand too, what occurs during a decision?




Aucun commentaire:

Enregistrer un commentaire