Mean line segment length

Even for simple shapes such as a square or a triangle, solving for the exact value of their mean line segment lengths can be difficult because their closed-form expressions can get quite complicated.

For the two-dimensional case, this is defined using the distance formula for two points (x1, y1) and (x2, y2) Since computing the mean line segment length involves calculating multidimensional integrals, various methods for numerical integration can be used to approximate this value for any shape.

To approximate the mean line segment length of a given shape, two points are randomly chosen in its interior and the distance is measured.

After several repetitions of these steps, the average of these distances will eventually converge to the true value.

[1] For a triangle with side lengths a, b, and c, the average distance between two points in its interior is given by the formula[2] where

If the two points are instead chosen to be on different sides of the square, the average distance is given by[3][4] The average distance between points inside an n-dimensional unit hypercube is denoted as Δ(n), and is given as[5] The first two values, Δ(1) and Δ(2), refer to the unit line segment and unit square respectively.

This constant has a closed form,[6] Its numerical value is approximately 0.661707182... (sequence A073012 in the OEIS) Andersson et.

al. (1976) showed that Δ(n) satisfies the bounds[7] Choosing points from two different faces of the unit cube also gives a result with a closed form, given by,[4] The average chord length between points on the circumference of a circle of radius r is[8] And picking points on the surface of a sphere with radius r is [9] The average distance between points inside a disk of radius r is[10] The values for a half disk and quarter disk are also known.

[11] For a half disk of radius 1: For a quarter disk of radius 1: For a three-dimensional ball, this is More generally, the mean line segment length of an n-ball is[1] where βn depends on the parity of n, Burgstaller and Pillichshammer (2008) showed that for a compact subset of the n-dimensional Euclidean space with diameter 1, its mean line segment length L satisfies[1] where Γ denotes the gamma function.

100,000 line segments are randomly generated inside a unit square, giving an approximate mean length of 0.5212.
Monte Carlo method to approximate the mean line segment length of a unit square .