Wednesday, October 17, 2012

Pr[a/b starts with 1]

PROBLEM

Suppose a,b are random real numbers. What's the probability that the first non-zero digit of (a/b) is 1?

E.g., the first non-zero digit in .01234 is 1

I found this problem on the blog http://republicofmathematics.blogspot.com/2011/10/world-quant.html


SOLUTION

So I ran some C++ simulations to find that the answer is around 1/3. But how do we prove that? Let's assume that a,b are drawn from uniform (0,1). We will represent the set of pairs (a,b) as a 1x1 square s.t. the lower left corner has coordinates (a=0,b=0); the lower right corner has coordinates (a=0,b=1); the upper right corner has coordinates (a=1,b=1).

Where are the points (a,b) such that .1<=a/b<.2? That's the triangle with coordinates (a=0,b=0), (a=.1,b=1), (a=.2, b=1). The area of that triangle is (.2-.1)/2. Similarly, the points s.t. .01<=a/b<.02 is a triangle with area (.02-.01)/2. We can sum up the areas corresponding to fractions .1*, .01*, .001*, .0001*, ..., where * is a mask for an arbitrary number of arbitrary digits, as follows:

(.2-.1)/2 + (.02-.01)/2 + (.002-.001)/2 + ... = .1/2 (1+.1+.01+.001...) = .05 * 10/9 = .5 / 9

Similarly, the total area for fractions 1.*, 1?.*, 1??.*, 1???.*, ..., where ? represents a single arbitrary digit, can be computed as follows.

(1/1-1/2)/2 + (1/10-1/20)/2 + (1/100-1/200)/2 + ... = .5/2 * (1 + .1 + .01 + .001 + ...) = .5/2 (10/9) = 5/18

We can add the two areas to get the probability that we were looking for:
.5/9 + 5/18 = 1/3

The following image shows the area that we are computing: