Library · Geometric Probability · Chapter 45
Sylvester’s four-point problem in a square
Problem 45.1
Let be four points chosen independently and uniformly at random in the unit square. What is the probability that they form the vertices of a convex quadrilateral?
Solution. Exactly as in Chapter 43, the disjoint-events dichotomy gives and the probability on the right equals .
By the expected-area computation in Chapter 44, and the unit square has area . Therefore which reduces to
Two points of comparison, showing how the convex-position probability depends on the shape of the region :
| numerically | ||
| triangle | ||
| square | ||
| disc |
The monotonic increase reflects intuitively that a “rounder” shape makes it harder for one of the four random points to be trapped inside the triangle of the other three. Sylvester’s original 1864 problem was to find the shape minimising ; Blaschke proved in 1917 that the triangle is the extremal case (and so the value of Chapter 43 is the minimum over all convex regions).
import numpy as np
N = 10**6
u, v = np.random.rand(2, 4, N)
def inside_tri(pu, pv, au, av, bu, bv, cu, cv):
det = (bv-cv)*(au-cu) + (cu-bu)*(av-cv)
w1 = ((bv-cv)*(pu-cu) + (cu-bu)*(pv-cv)) / det
w2 = ((cv-av)*(pu-cu) + (au-cu)*(pv-cv)) / det
w3 = 1 - w1 - w2
return (w1 > 0) & (w2 > 0) & (w3 > 0)
any_in = np.zeros(N, dtype=bool)
for i in range(4):
j, k, l = [m for m in range(4) if m != i]
any_in |= inside_tri(u[i], v[i], u[j], v[j], u[k], v[k], u[l], v[l])
print(f"sim: {(1 - any_in).mean():.5f} exact: {25/36:.5f}")
# sim: 0.69465 exact: 0.69444