how to derive following solution for uniform distributions?

Hi, I have the following situation.

In a rectangular cartesian coordinate of length L and breadth B, you choose any two points randomly (i.e. you choose random X and random Y for both the points) using random uniform distribution.

You then calculate the distance between them (simple linear distance given by pythagorean theorem on x and y differences).

By simulation I can find the mean value of d for given values of L and B, however, I need a general formula to derive this.

Does anyone have an idea how to do this?

(From simulation, for square of length 1, mean d =0.5; but for rectangles, i couldnt find any pattern)
d is a transformation of two random variables, and hence, is a random variable itself. Where:

X ~ Unif(0,1)
Y ~ Unif(0,1)
d = sqrt(X^2 + Y^2)

We know that the range of this variable is from 0 to sqrt(2). From simulation, I found the mean to be 0.765. The distribution of the generated observations is not that of any distribution I recognize. Also, I imagine that the pdf of d would be difficult to deduce analytically.

It appears that you had calculated the distance d as:

d = sqrt(X^2 - Y^2)

which is not the formula for euclidean distance.

In this case however, you will find that the simulated mean will be 0.5. However, the distribution of this second d is also a mystery.

Tough problem :mad:

clearing up some

Hi Matt,
thanks for putting the effort,
but you see, actually, you seem to have made another simplifying assumption giving you a wrong answer in simulations as well.

so if we choose two points, A(x1, y1) and B(x2,y2), the distance is given by:

d = ( (x2-x1)^2 + (y2-y1)^2 )^1/2

where all x1, x2, y1, y1 ~Unif(0,1)

trying a simulation of this indeed gives something around 0.52.

Thinking about this further,

(x2-x1) and (y2-y1) both distribute in a triangular distrubution as explained in

the trick is find what the distribution for two of those squared and added together would look like.

all help would be appreciated
Ah. I see. Tried it again...

simulation results:
x1 <- runif(1000000)
x2 <- runif(1000000)
y2 <- runif(1000000)
y1 <- runif(1000000)

d <- sqrt((x2-x1)^2 + (y2-y1)^2)

Min. 1st Qu. Median Mean 3rd Qu. Max.
0.0009053 0.3285000 0.5119000 0.5213000 0.7038000 1.3910000

skew - 0.1850057
kurtosis - -0.6581672

So, Its bounded, and skewed, (not symmetric), and the mean is > 0.5

We also know that the random quantity d must be between 0 and sqrt(2).

I don't imagine that this distribution has a form that you will be able to find on the internet. I'm sure that it can be found by transformation, but it will be messy.

Also, you can take the R code above and look at a histogram of d to see what it would look like.