mercredi 16 novembre 2016

How to generate a random number from a uniform distribution in php?

I am trying to generate a random number from a uniform distribution in php using $group = rand(0,8). I ran my experiment around 200 times and I get the following distribution which suggests that all groups do not have an equal probability of being selected.

Group |  Freq.    Percent      Cum.
------+------------------------------
0     |  20        9.52        9.52
1     |   4        1.90       11.43
2     |  25       11.90       23.33
3     |  32       15.24       38.57
4     |  27       12.86       51.43
5     |  22       10.48       61.90
6     |  30       14.29       76.19
7     |  24       11.43       87.62
8     |  26       12.38      100.00
------+-------------------------------
Total |  210      100.00

I read the discussion thread here PHP: rand() or array_rand trouble and the only reason I ask this question is because I am new to php and don't know whether I should use:




Aucun commentaire:

Enregistrer un commentaire