Let A and B each be random real numbers chosen from the uniform interval (0,1).
Call X the first nonzero digit of A+B.
Call Y the first nonzero digit of AB.
Call Z the first nonzero digit of A/B.
Find the probability distribution of each random variable.
The sample space is a square on the AB plane.
Addition (+):
The upperright half will produce solely the leading digit 1.
Just down and to the left of that region is a trapezoid in which the lead digit is 9, as the sums are from .9 up to almost 1. Its base is sqrt(2) and the length of each nonparallel side is .1, making the height of this 45° trapezoid .1/sqrt(2), and the length of its shorter parallel side is .9*sqrt(2).
The area of this trapezoid is then ((1+.9)*sqrt(2)*.1/sqrt(2)) / 2 = (1+.9)*.1/2 = .095 for the first trapezoid to be devoted to the digit 9.
The next trapezoid down and to the left has the same height as the first, but its base is 9/10 that of the base of the first and its shorter parallel side is 8/9 that of the first. Its area is ((.9+.8)*sqrt(2)*.1/sqrt(2)) / 2 = (.9+.8)*.1/2 = .085 as the first of the trapezoids to be devoted to the digit 8
This continues predictably and is summarized in the table of first digits for sums between 0.1 up to almost 1:
digit
9 (1+.9)*.1/2 = .095
8 (.9+.8)*.1/2 = .085
7 (.8+.7)*.1/2 = .075
6 (.7+.6)*.1/2 = .065
5 (.6+.5)*.1/2 = .055
4 (.5+.4)*.1/2 = .045
3 (.4+.3)*.1/2 = .035
2 (.3+.2)*.1/2 = .025
1 (.2+.1)*.1/2 = .015
Then follow trapezoids for the same nine digits when they are prefaced by a single zero after the decimal point, and then by a set for double zeros, etc.
Each set of nine trapezoids is 1/10 the linear dimension of the one preceding, and therefore 1/100 the area. The sum of the trapezoids for any given digit is therefore the number given in the table above multiplied by 1.01010101... = 100/99. When this is done to each of the numbers, they do indeed total to .5, as they occupy the lower left half of the unit square.
digit first trapezoid * 100/99 final probability decimal version
9 19/198 19/198 = 19/198 0.0959595959595959595
8 17/198 17/198 = 17/198 0.0858585858585858585
7 15/198 15/198 = 5/66 0.0757575757575757575
6 13/198 13/198 = 13/198 0.0656565656565656565
5 11/198 11/198 = 1/18 0.0555555555555555555
4 9/198 9/198 = 1/22 0.0454545454545454545
3 7/198 7/198 = 7/198 0.0353535353535353535
2 5/198 5/198 = 5/198 0.0252525252525252525
1 3/198 3/198 + 1/2 = 17/33 0.5151515151515151515
Of course the 1/2 was added to the trapezoids for 1 as the entire upper right triangle belongs to 1.
This agrees with a simulation
DEFDBL AZ
DO
x = RND(1)
y = RND(1)
p = x + y
ps$ = STR$(p)
FOR i = 1 TO LEN(ps$)
ix = INSTR("123456789", MID$(ps$, i, 1))
IF ix > 0 THEN EXIT FOR
NEXT
hit(ix) = hit(ix) + 1
ct = ct + 1
FOR i = 1 TO 9
PRINT hit(i);
NEXT: PRINT
FOR i = 1 TO 9
PRINT USING " #.#####"; hit(i) / ct;
NEXT: PRINT
LOOP
which when interrupted showed:
200686 9747 13720 17789 21639 25451 29610 33039 37241
0.51601 0.02506 0.03528 0.04574 0.05564 0.06544 0.07613 0.08495 0.09575
Subtraction ():
Here the dividing line is the line A = B. The leading digits are symmetrical with respect to this line, the only difference being the sign of the result, which is not counted.
The trapezoids are the same as in the addition case, except that the largest one in each set is for the digit 1 and the smallest for the digit 9. Again, the other triangular half of the square is a reflection of the one divided into trapezoids rather than being a single solid digit the way it was for addition.
So the table has 99 in the denominator rather than 198, to account for the doubling of the trapezoids as per reflection, in addition to the reversal of the identity of the digits:
digit probability reduced decimal
1 19/99 19/99 0.1919191919191919191
2 17/99 17/99 0.1717171717171717171
3 15/99 5/33 0.1515151515151515151
4 13/99 13/99 0.1313131313131313131
5 11/99 1/9 0.111111111111111111
6 9/99 1/11 0.090909090909090909
7 7/99 7/99 0.070707070707070707
8 5/99 5/99 0.050505050505050505
9 3/99 1/33 0.030303030303030303
Simulation with subtraction verifies these numbers:
61489 55144 49118 42025 35643 29143 22853 16165 9837
321417 total trials
0.19131 0.17157 0.15282 0.13075 0.11089 0.09067 0.07110 0.05029 0.03061

Posted by Charlie
on 20090824 15:31:04 