Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

My question is similar to this one but for rectangles instead of lines.

Suppose I have a rectangle with sides of length $L_w$ and $L_h$. What is the average distance between two uniformly-distributed random points inside the rectangle, and why?

share|improve this question
Related: stats.stackexchange.com/q/22488/2970 –  cardinal Oct 7 '12 at 14:32

2 Answers 2

up vote 6 down vote accepted

The answer, given here and here, is

$$ \frac1{15} \left( \frac{L_w^3}{L_h^2}+\frac{L_h^3}{L_w^2}+d \left( 3-\frac{L_w^2}{L_h^2}-\frac{L_h^2}{L_w^2} \right) +\frac52 \left( \frac{L_h^2}{L_w}\log\frac{L_w+d}{L_h}+\frac{L_w^2}{L_h}\log\frac{L_h+d}{L_w} \right) \right)\;, $$

where $d=\sqrt{L_w^2+L_h^2}$.

share|improve this answer
+1. Good find. $ $ –  Did Oct 7 '12 at 12:02
It seems to be a simple problem. But it's not. Good find. (+1) –  Patrick Li Oct 7 '12 at 14:18

You can split your two points into coordinates. From the problem you've linked we know that: the expectated distance is $E = \frac{L}{3}$.

Now, assuming that coordinates are independent you can apply the result to the rectangle considering the orthogonal sides as lines, so: $$E_w = \frac{L_w}{3} $$ $$E_h = \frac{L_h}{3} $$ $$d = \sqrt{L_w^2 + L_h^2}$$ $$E_d = \frac{\sqrt{L_w^2 + L_h^2}}{3} $$

share|improve this answer
The fact that the coordinates are independent doesn't imply that the square and square root and the expectation commute. –  joriki Oct 7 '12 at 11:41
Sorry, the answer seemed to be so obvious... but it wasn't. –  Blex Oct 7 '12 at 12:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.