Library · Geometric Probability · Chapter 18
Intersections among n random chords
Problem 18.1
Let chords be drawn independently on a circle, each chord defined by two independent uniform random endpoints on the circle. What is the expected number of pairs of chords that cross each other?
Solution. Let be the number of pairs of crossing chords. Write , where is the indicator of “chord crosses chord ”.
By Chapter 12, each individual pair of chords (defined by independent uniform endpoints) crosses with probability . Hence for every pair .
By linearity of expectation (even though the are not independent, linearity still applies), Therefore
For we expect crossings, for some . This quadratic growth in — a direct consequence of summing pair indicators and applying linearity of expectation — is the foundation of many probabilistic-combinatorial arguments (“each pair of objects contributes its to the mean”). The indicators are not independent — two pairs sharing a chord are correlated — but linearity needs no independence. By Markov’s inequality one can quickly bound the number of crossings above; tighter bounds come from second-moment or martingale methods. The special case reproduces Chapter 12’s answer .
import numpy as np
# Count crossings among n=5 chords using the geometric side-test from the two-chord crossing problem.
n, N = 5, 10**5
theta = np.random.rand(2*n, N) * 2*np.pi
x, y = np.cos(theta), np.sin(theta)
def side(A, B, C):
return (B[0]-A[0])*(C[1]-A[1]) - (B[1]-A[1])*(C[0]-A[0])
total = np.zeros(N)
for i in range(n):
for j in range(i+1, n):
A, B = (x[i], y[i]), (x[n+i], y[n+i])
C, D = (x[j], y[j]), (x[n+j], y[n+j])
cr = (np.sign(side(A,B,C))*np.sign(side(A,B,D)) < 0) & \
(np.sign(side(C,D,A))*np.sign(side(C,D,B)) < 0)
total += cr
print(f"sim: {total.mean():.4f} exact: {n*(n-1)/6:.4f}")
# sim: 3.3283 exact: 3.3333