lundi 12 mars 2018

python random.randint vs random.choice: different outcomes usingsame values

I asked my students to write a python program in which the results of 100 rolls of a pair of 6-sided dice were stored in a list and then plotted in a histogram.

I was treating random.choice(1,2,3,4,5,6) as inferior to random.randint(1,6), until I noticed that the histograms of the students who used random.choice better reflected expected outcomes. For example, the occurrence of rolls of 12 (6+6) was unnaturally high in nearly all histograms of students who used random.randint(1,6). Does anyone have an idea of what's going on?




Aucun commentaire:

Enregistrer un commentaire