What is the likelihood of two line segments crossing?

Let's be perfectly clear about the assumptions. I assume that "randomly selecting 4 points" A,B,C,D in the unit square means selecting uniformly and independently at random their coordinates $x_A,y_A,x_B...$ in the $[0,1]$ range; and that one of the 6 possible pairings between points to form the segments is also chosen uniformly and independently at random -- so the problem is equivalent to asking what is the probability that, e.g. AC and BD intersect.


It's easy to see that the solution is $\frac{25}{108}$, or about $23\%$, if one is willing to take as a given the solution for Sylvester's four-point problem for the square -- the probability that the convex hull of four points chosen uniformly and independently at random in a square is a quadrilateral, which is $\frac{25}{36}$. It is immediate to see that two segments chosen by a random pairing of four points intersect if, and only if, the convex hull of the four points is indeed a quadrilateral, and the two segments are its diagonals. If the former condition is satisfied, the latter happens with probability $\frac{1}{3}$ (the probability that a given point is paired with "middle one" of the remaining three), yielding a solution of $\frac{25}{36}\cdot\frac{1}{3}=\frac{25}{108}$ for the original problem.


Sylvester's four-point problems allows one to obtain the answer in exactly the same way even if the points are chosen uniformly at random in another convex region, simply by multiplication by $\frac{1}{3}$. The general formula for Sylvester's four-point problem in a convex region $R$, as given in the above link, equals $1-4\frac{\bar{A_R}}{A(R)}$ where $A(R)$ is the area of the region (in the case of the unit square, $1$) and $\bar{A}_R$ equals the expected area of a triangle obtained from $3$ points chosen uniformly at random within it. The formula is easily obtained noting that probability that one given point lies within the triangle formed by the other $3$ is $\frac{\bar{A_R}}{A(R)}$, and since the events of this happening for different points are mutually exclusive, the probability that no point lies within the triangle formed by the other three is indeed $1-4\frac{\bar{A}_R}{A(R)}$.

Computing $\frac{\bar{A_R}}{A(R)}$ is non-trivial, in general. If R is a square (our case), a simple proof that $\frac{\bar{A_R}}{A(R)}=\frac{11}{144}$ can be found here. More in general if R is regular polygon of $n$ sides the solution is given by Alikosky's formula, $\frac{\bar{A_R}}{A(R)}=\frac{9\cos^2 (2\pi/n)+52\cos(2\pi/n)+44}{36n^2\sin^2(2\pi/n)}$. Note that this is a strictly decreasing function of $n$, so the intersection probability is strictly increasing with $n$, and the limit for $n\to\infty$, i.e. $\frac{35}{48\pi^2}$, yields the solution when picking points in the circle.

So, in general, the probability of intersection of $2$ segments, each made by $2$ points chosen uniformly and independently at random from a regular $n$-agon or any of its affine transformations (such as a rectangle or parallelogram) is:

$\frac{1}{3}\left(1-4\cdot\frac{9\cos^2(2\pi/n) + 52\cos(2\pi/n) + 44}{36 n^2\sin^2 (2\pi/n)}\right)$

with the limit for $n\to\infty$, i.e. $\frac{1}{3}-\frac{35}{36\pi^2}$, yielding the probability when choosing the points from a circle (or any affine transformation, such as an ellipse).


First let's select 4 points inside a square. Let $P_c$ be a probability that these 4 points form a convex figure (none of the selected points is inside the triangle formed by the other three).

If this is the case, the probability that two line segments intersect is 1/3.

Otherwise the probability is 0.

So, the probability we are looking for is:

$P=1/3 * P_c$

Now we need to find the $P_c$.

Let's calculate the probability $P_1$ that the first point is inside the triangle formed by the three others. It is $P_1 = S_{234}/S_{square}$, where $S_{234}$ is the expected area of the triangle formed by points 2, 3 and 4.

Same for $P_2$, $P_3$ and $P_4$. Obviously $P_1=P_2=P_3=P_4$.

Probability that any point is inside of triangle formed by other 3 is $P_1+P_2+P_3+P_4$ because no more than 1 of these outcomes can happened simultaneously.

$P_c = 1 - 4*P_1 = 1 - 4 * S_{234}$

And now we only need to find $S_{234}$ - expected area of a triangle formed by randomly selected 3 points inside a square.

The expected area of a triangle formed by three points randomly chosen from the unit square

They say it is $11/144$.

$P=1/3 * (1 - 4*11/144) = 25/108$

This is in a good agreement with my experiments.