On a regular two dimensional coordinate plane, you have a square with side length 1 unit.
Pick a point within the square at random, and from there travel a random but straight direction .5 units.
What is the probability that you end up still within the square?
Let A with coordinates (x,y) be the first point picked in the unit square and B with coordinates (u,v) be the second point picked. Then we can express u and v as follows:
u=x+r.cos(t) and v=y+r.sin(t) for r=0.5 and a random angle t between 0 and 2(pi) radians..
Then required proability is P[0<=x<=1, 0<=y<=1, 0<=x+u<=1, and0<=y+v<=1]
which is then
P[Max(0,r.cos(t)) <= x <= Min(1,1r.cos(t)) and
Max(0,r.sin(t)) <=y<=Min(1,1r.sin(t))]
Let D denote the event above.
We will evaluate P(D) by finding P(Dt) the conditional probability of D given that the directional angle is t and then integrating out t over the interval (0,2.pi) with weight (1/2.pi).
We do this for four seprate intervals of t of length pi/2.
Case 1: Fix a t in [0,pi/2]. Then both sin(t) and cos(t) >= 0. So we need 0<=x<=(1r.cost(t)) and
0<=y<=(1r.sin(t)). Hence P(Dt)=(1r.cost(t)).(1r.sin(t)). Thus by integrating P(Dt) over [0,pi/2], we get [tr.sin(t)+r.cost(t)r*r/4.cos(2t)] evaluated between t=0 and t=pi/2.
Its value is (pi/2)2r+r*r/2 = a (say)
Case 2: T lies in [pi/2,pi]. Here cost(t)<=0 and sin(t)>=0. So we need rcost(t)<=x<=1 and 0<=y<=1r.sin(t). Thus, P(Dt)=(1+r.cos(t))(1r.sin(t)).
Its integral over [pi/2,pi] also evaluates the same quantity a.
Similarly the cases 3 and 4 with t in [pi,3.pi/2] and [3.pi/2,2.pi] yield the same value a.
It is intuitively clear that in each of the four arcs of the circle, the probabilities should be the same.
Hence the required probability is 4a/2.pi=2a/pi.
Now by setting r=0.5 we get a=(pi/2)1+(1/8)=(pi/2)7/8.
Hence the required probability for r=0.5 is (2/pi).[(pi/2)(7/8)]=1(7/4.pi)=0.44 (appx).

Posted by Prab
on 20031105 20:44:12 