# Distance between random points

October 18 2013

0

This post in reply to the Question, Distance between random points

The question was "Let X be the random variable uniformly distributed in the disk centered at the origin O(0,0) with radius 1 and let Y be the random variable uniformly distributed in the square having its vertices A(6,-1), B(9,-2), C(8,-5), and E(5,-4). What is the PDF of the distance between X and Y? Is it possible to find that with Maple?"
Having a long think about the topic, I draw the conclusion that the exact closed form of the PDF/CDF, even the one can be found, would be useless because of its complexity.
Thus, an approximate formula for the CDF/PDF under consideration is a proper way. That formula can be derived in such a way. First,rotating the picture, we may consider the square having its sides horizontal or vertical: K((1/5)*sqrt(1410)-(1/2)*sqrt(10),1/sqrt(10)), L((1/5)*sqrt(1410)+(1/2)*sqrt(10),1/sqrt(10), M((1/5)*sqrt(1410)+(1/2)*sqrt(10),1/sqrt(10)-sqrt(10)), Q((1/5)*sqrt(1410)-(1/2)*sqrt(10),1/sqrt(10)-sqrt(10)). The geometry behind that is omitted.
We randomly choose a point P1 belonging to the square [-1,1] x [-1.1]. If the one belongs to the disk {(x,y):x^2+y^2 <=1}, then we randomly choose a point P2 from the square [K,L] x [Q,L]. Next, we calculate the distance between P1 and P2 (The  LinearAlgebra[Norm] command http://www.maplesoft.com/support/help/Maple/view.aspx?path=LinearAlgebra/Norm is used to this end.) and add it to the set S.This is repeated 2*10^4 times.

Converting S to an Array A, we constuct the empirical distribution X by A and find its mean mu and standard deviation sigma.

7.67568900820260

1.029831470

Let us compare the obtained empirical distribution and the normal distribution with the parameters mu and sigma.

The plot suggests a good fit between these. However, it is only semblance. Applying the Kolmogorov-Smirnov test (for example, see  http://www.mapleprimes.com/posts/119903-The-KolmogorovSmirnov-Test
), we  calculate

and

3.32619143372726

while the critical value equals 1.358098639 at the level 0.05. Thus, the hypothesis about the concordance should be rejected.

Also we draw the approximation to the PDF:

CDF.mw

﻿