4
$\begingroup$

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!

$\endgroup$
6
  • 1
    $\begingroup$ Do we know anything about this two straight lines segment (like if they are subsets of $\mathbb{R}^n$ for some $n$)? Also do you mean Uniformly distributed right? $\endgroup$
    – JayTuma
    Aug 10, 2018 at 9:55
  • 1
    $\begingroup$ These lines are R^n for n = 2. I have the lines coordinates of start and end. Yes, uniformly distributed. $\endgroup$ Aug 10, 2018 at 10:28
  • $\begingroup$ This can be set up easily as a double integral, but I doubt there's any simplification in the general case. $\endgroup$ Aug 10, 2018 at 14:31
  • $\begingroup$ You don't specify the orientation of the two lines. See this for one particular orientation: math.stackexchange.com/questions/2505978/… $\endgroup$
    – Dean
    Aug 10, 2018 at 18:06
  • $\begingroup$ Is the expected value of the distance squared of any interest? Things simplify quite nicely in that case. For the expected value of distance, the problem becomes an integral of the square root of a quadratic form over a rectangle in $\mathbb R^2$, which could perhaps be evaluated with some effort. $\endgroup$
    – Kajelad
    Aug 10, 2018 at 22:28

1 Answer 1

1
$\begingroup$

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.

$\endgroup$
13
  • $\begingroup$ Hi, Kajelad thanks for your answer! Is this solution can be employed for all situations (different lengths, directions, locations, overlayed, cross-crossed)? $\endgroup$ Aug 16, 2018 at 13:03
  • $\begingroup$ This way of stating the problem makes no assumptions about length, orientation, crossings, etc. Both the rms and expected difference are well behaved in every case. $\endgroup$
    – Kajelad
    Aug 16, 2018 at 21:11
  • 1
    $\begingroup$ There was a typo in the coefficients. After fixing it, the resulting integral for that example is $$\frac L8\int_{-1}^1\int_{-1}^1\sqrt{t_1^2+t_2^2-2t_1t_2}\ dt_1dt_2$$, giving the correct result of $\langle d\rangle = \frac L3$. $\endgroup$
    – Kajelad
    Aug 17, 2018 at 16:42
  • 1
    $\begingroup$ Using $\vec v_1$, $\vec v_2$ chosen to be parallel, you get $A=B_1=B_2=0$, $C_1=C_2=L^2/4$, and $C_3=-L^2/2$. Plugging these in gives: $$ \langle d\rangle=\frac 14\int_{-1}^1\int_{-1}^1\sqrt{\frac{L^2}{4}t_1^2+\frac{L^2}{4}t_2^2-\frac{L^2}{2}t_1 t_2}\ \ dt_1dt_2 $$ The $L^2/4$ can be factored out of the square root. $\endgroup$
    – Kajelad
    Aug 23, 2018 at 19:13
  • 1
    $\begingroup$ Also, if you're having issues with numerics, it might be sufficient to take the absolute value of the argument of the square root. Numerical error could cause this to be negative near a crossing, but otherwise the function is well-behaved. $\endgroup$
    – Kajelad
    Aug 23, 2018 at 19:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .