const size_t TOTAL=1ul<<32;
uint32_t *tally = calloc(TOTAL, sizeof(*tally));
for (size_t i=0; i<TOTAL; i++)
tally[arc4random()&(TOTAL-1)]++;
uint32_t count[32] = {0};
for (size_t i=0; i<TOTAL; i++)
count[tally[i]]++;
for (uint32_t i=0; i<32; i++)
if (count[i])
printf("%u %u %lf\n", i, count[i], (double)count[i]/TOTAL);
0 1580026442 0.367879
1 1580006452 0.367874
2 790052346 0.183948
3 263344671 0.061315
4 65825267 0.015326
5 13159560 0.003064
6 2194752 0.000511
7 313184 0.000073
8 39669 0.000009
9 4466 0.000001
10 437 0.000000
11 45 0.000000
12 5 0.000000
./a.out 709.23s user 5.57s system 99% cpu 11:54.94 total
The curious thing is the first two numbers (count of numbers arc4random didn't produce, and count of those only produced once) are almost exactly 1/e. Is anyone who knows statistics here & can tell me why?