Average distance detween two random points on two line segments

609 Views Asked by At

Suppose you have two straight line of length $L_1$ and $L_2$, and a point is chosen at random along each line.

What is the expected distance between these points?

This question is a complement of Average Distance Between Random Points on a Line Segment.

Best regards!

1

There are 1 best solutions below

13
On BEST ANSWER

I'll refer to the endpoints of each line as $\vec a_1, \vec b_1$ and $\vec a_2, \vec b_2$ for lines $1$ and $2$. To parameterize them, I'll use vectors $\vec u$ and $\vec v$. $$ \vec u_1=\frac{\vec a_1+\vec b_1}{2},\ \ \ \vec v_1=\frac{\vec a_1-\vec b_1}{2} \\ \vec u_2=\frac{\vec a_2+\vec b_2}{2},\ \ \ \vec v_2=\frac{\vec a_2-\vec b_2}{2} $$ Then, we can define the lines themselves as: $$ L_1=\{\vec u_1+t_1\vec v_1:\ t_1\in[-1,1]\} \\ L_2=\{\vec u_2+t_2\vec v_2:\ t_2\in[-1,1]\} $$ A uniform probability distribution would have a value of $\frac 12$ for all $t$. We can find the expected distance squared with the following integral: $$ \langle d^2\rangle=\frac 14\int_{-1}^1\int_{-1}^1||(\vec u_1+t_1\vec v_1)-(\vec u_2+t_2\vec v_2)||^2dt_1dt_2 $$ regrouping terms: $$ \langle d^2\rangle=\frac 14\int_{-1}^1\int_{-1}^1||(\vec u_1-\vec u_2)+t_1\vec v_1-t_2\vec v_2||^2 dt_1dt_2 $$ When we distribute the dot products, we obtain a quadratic function of $t_1$ and $t_2$ with the following coefficients: $$ A=||\vec u_1-\vec u_2||^2 \\ B_1=2\vec v_1\cdot(\vec u_1-\vec u_2),\ \ \ B_2=-2\vec v_2\cdot(\vec u_1-\vec u_2) \\ C_1=||\vec v_1||^2,\ \ \ C_2=||\vec v_2||^2,\ \ \ C_3=-2\vec v_1\cdot\vec v_2 \\ $$ Rewriting the integral: $$ \langle d^2\rangle=\frac 14\int_{-1}^1\int_{-1}^1\left(A+B_1t_1+B_2t_2+C_1t_1^2+C_2t_2^2+C_3t_1t_2\right)dt_1dt_2 $$ Here, all the terms containing an odd power of $t_1$ or $t_2$ vanish by symmetry, which leaves us with a compact result. $$ \tag{1} \langle d^2\rangle=A+\frac 13(C_1+C_2)=||\vec u_1-\vec u_2||^2+\frac 13\left(||\vec v_1||^2+||\vec v_2||^2\right) $$ The square root of this quantity, the RMS disntance, is a slightly different measure of the "typical" distance between points. If we want to compute the true expected value of distance, then the resulting integral permits no such simplifications. $$ \tag{2} \langle d\rangle=\frac 14\int_{-1}^1\int_{-1}^1\sqrt{A+B_1t_1+B_2t_2+C_1t_1^2+C_2t_2^2+C_3t_1t_2}\ dt_1dt_2 $$ It's quite possible that this expression can be coerced into some kind of elliptic integral, but I doubt there is a simple way to do so.