All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Random +, - or / Random (Posted on 2009-08-24)
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 A-B.
Call Z the first nonzero digit of A/B.

Find the probability distribution of each random variable.

 See The Solution Submitted by Jer No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 + and - solution | Comment 1 of 2

The sample space is a square on the A-B plane.

The upper-right 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 non-parallel 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 = .0958 (.9+.8)*.1/2 = .0857 (.8+.7)*.1/2 = .0756 (.7+.6)*.1/2 = .0655 (.6+.5)*.1/2 = .0554 (.5+.4)*.1/2 = .0453 (.4+.3)*.1/2 = .0352 (.3+.2)*.1/2 = .0251 (.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 version9             19/198             19/198       =  19/198    0.09595959595959595958             17/198             17/198       =  17/198    0.08585858585858585857             15/198             15/198       =   5/66     0.07575757575757575756             13/198             13/198       =  13/198    0.06565656565656565655             11/198             11/198       =   1/18     0.05555555555555555554              9/198              9/198       =   1/22     0.04545454545454545453              7/198              7/198       =   7/198    0.03535353535353535352              5/198              5/198       =   5/198    0.02525252525252525251              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 A-Z
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  372410.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          decimal1             19/99         19/99     0.19191919191919191912             17/99         17/99     0.17171717171717171713             15/99         5/33      0.15151515151515151514             13/99         13/99     0.13131313131313131315             11/99         1/9       0.1111111111111111116              9/99         1/11      0.0909090909090909097              7/99         7/99      0.0707070707070707078              5/99         5/99      0.0505050505050505059              3/99         1/33      0.030303030303030303`

Simulation with subtraction verifies these numbers:

`61489  55144  49118  42025  35643  29143  22853  16165  9837321417 total trials0.19131 0.17157 0.15282 0.13075 0.11089 0.09067 0.07110 0.05029 0.03061`

 Posted by Charlie on 2009-08-24 15:31:04

 Search: Search body:
Forums (0)