Given uniformly randomly chosen x on the interval (1,5) and y on the interval (1,5) find the probability of each:
[x] + [y] = [x+y]
[x] - [y] = [x-y]
[x] * [y] = [x*y]
[x] / [y] = [x/y]
Where [x] is the floor function, the greatest integer less than or equal to x.
[x] + [y] = [x+y]
If the fractional parts (portions after the decimal) add up to less than 1, the two will be equal, otherwise unequal. The probability is zero that they'd add to exactly 1, so that can be ignored. If the fractional parts are plotted on coordinate axes, the resulting unit square is divided by a diagonal line from (0,1) to (1,0) separating these two equal areas. The probability is 1/2.
[x] - [y] = [x-y]
This is the same as the addition case except that for the y, it's 1 minus the fractional part. The probability is still 1/2.
[x] * [y] = [x*y]
When [x] = 1, and [y] = 1 this tests if xy<=2. Graphed, this is the portion of the unit square from (1,1) to (2,2) that is under the hyperbola y=2/x. That is 2*ln(2) - 1. We subtract 1 because this unit square has another unit square below it, i.e., its base is not the x-axis.
Similar calculations need to be done for each of the 16 unit squares with lower left corners from (1,1) to (4,4) (not necessarily equal x and y). In the general case the integration does not proceed all the way to the next integer of x, but only to where the hyperbola cuts the lower y value, b, which is at x = (a*b+1)/b = a + 1/b. For any pair (a,b) as the lower left corner of the square we need
Integ{a,a+1/b} (a*b+1)/x dx - b/b = ((a*b+1)*ln x){eval a to a+1/b} - 1
= (a*b + 1)*(ln(a+1/b) - ln(a)) - 1
So overall we need:
(Sigma{a=1 to 4} Sigma{b=1 to 4} ( (a*b + 1)*(ln(a+1/b) - ln(a)) - 1 )) / 16
as we need to average over the 16 squares.
10 for A=1 to 4
20 for B=1 to 4
30 Term=(A*B+1)*(log(A+1/B)-log(A))-1
40 T=T+Term:print Term
50 next
60 next
70 print:print T/16
a b 1 2 3 4
1 .3862943611198906187 .2163953243244931449 .150728289807123711 .1157177565710487771
2 .2163953243244931449 .1157177565710487771 .0790547587908081287 .0600473209074510894
3 .1507282898071237086 .0790547587908081279 .0536051565782630099 .0405551997559735324
4 .1157177565710487771 .0600473209074510894 .0405551997559735331 .0306185708793923204
It's a good sign that when a and b are interchanged we get the same result. The average of these values is 0.1194520715913994681.
Edited on May 18, 2007, 11:41 am
Edited on May 18, 2007, 11:41 am
|
Posted by Charlie
on 2007-05-18 11:26:33 |