1
$\begingroup$

I'm testing a Range function from big integer software libraries. The function will return an integer in the range [0,k), where k is the upper limit on the range. I'm seeing unexpected results, and I hope the CV folks can help point out my mistake.

Here's the pseudo code:

bins[65536];
for i = 0 to 1000000
{
    v = Range(0, 65536)
    bins[v] = bins[v] + 1
}

sort(bins)
low = bins[0]
high = bins[65535]

In the above, bins is just a count of the frequency. And sort is a sort of the bin based on the the frequency.

I expect to see each value (0 through 65535) about 15 times because 1000000 / 65536 ~= 15.

However, repeated runs of the program continually produce results similar to:

Low (`bins[0]`): 1 or 2
High (`bins[65535]`): 34 or 35

low is never above 2, and high is never less than 34 or so. I'm beginning to think this generator might have a bias.

Am I doing something wrong in my test? Or am I interpreting the results incorrectly?

(And sorry for yet another "Is this a uniform distribution" question).

$\endgroup$
3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy