I need to sample 10 uniformly distributed random numbers between 0 and 1. So I thought the following code in python would do this:
positions = []
for dummy_i in range(1000000):
positions.append(round(random.random(),1))
However when putting the result into a histogram the result looks as follows:
So the rounding seems to destroy the uniform distribution generated by random.random(). I wonder what causes this and how to prevent this from happening. Thanks for your help!
Aucun commentaire:
Enregistrer un commentaire