Library · Geometric Probability · Chapter 32
Expected area of a random rectangle
Problem 32.1
Let and be two points chosen independently and uniformly in the unit square. Let be the axis-aligned rectangle with diagonally opposite corners and . What is the expected area of ?
Solution. The area of the axis-aligned rectangle is . Since the pairs and are independent (the - and -coordinates of the two points are independent), so are and . Hence
Each factor is the expected absolute difference of two uniform random variables on . A direct calculation: for iid uniform on , the density of is on , so (Alternatively, by symmetry in the triangle : unconditionally, but conditional on , ; and the same value arises unconditionally for the absolute value.)
Hence
The factor for is such a frequent building block that it is worth knowing by heart; we meet it again in Chapter 33. The factor of here is a clean demonstration of the multiplicative structure of product measures.
import numpy as np
x1, x2 = np.random.rand(2, 10**7)
y1, y2 = np.random.rand(2, 10**7)
area = np.abs(x1 - x2) * np.abs(y1 - y2)
print(f"sim: {area.mean():.5f} exact: {1/9:.5f}")
# sim: 0.11114 exact: 0.11111