samedi 8 février 2020

Python: Random 0 1 generator with certain probabilities in a list or matrix

I need to put commas between 0 and 1 so I can make an histogram of the data.

This y my distributution but ¿there's a way to put commas like this in the array [0,0,0,1,0] or a direct way to make the histogram from it?

#20 is the number of columns that we will have for x in np.arange(0.05 , 1 , 0.2): t = np.array(np.random.rand( 20 ) < x , int) print (t)

And I get this output

[0 1 1 0 0 0 0 0 0 0]
[0 1 1 0 0 1 0 0 0 0]
[0 0 0 0 0 1 0 1 1 0]
[1 1 1 0 0 1 0 1 1 1]
[1 0 1 1 1 1 1 1 1 1]



Aucun commentaire:

Enregistrer un commentaire