[racket] a small programming exercise

From: Chris Stephenson (cs at cs.bilgi.edu.tr)
Date: Fri Oct 15 05:13:25 EDT 2010

On 15/10/10 11:33, Jos Koot wrote:
> When taking a long list of pseudo random positive integers most of which are
> far greater than the base, I expect about the same frequency for each first
> digit from 1 to base-1. This seems to hold if the base is a power of 10, but
> for other bases, e.g. base 24, I get rather unexpected results. See program
> below. Someone has an idea how this can happen?

That is exactly the effect that Shriram was looking for.

Think about the decimal numbers in the range 1-200. How many start with
1?- More than half. The range 1-1000 is an exception. But natural
distributions are not uniform over a fixed range. They are bell curves
of one sort or another. If you have a natural random distribution there
will always be a skew toward the smaller digits. It is quantified as
Benford's law.

Chris Stephenson
cs at cs.bilgi.edu.tr

Posted on the users mailing list.