Mean line segment length

From testwiki
Jump to navigation Jump to search

In geometry, the mean line segment length is the average length of a line segment connecting two points chosen uniformly at random in a given shape. In other words, it is the expected Euclidean distance between two random points, where each point in the shape is equally likely to be chosen.

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. As an example, consider the following question:

What is the average distance between two randomly chosen points inside a square with side length 1?

While the question may seem simple, it has a fairly complicated answer; the exact value for this is 2+2+5ln(1+2)15.

Formal definition

The mean line segment length for an n-dimensional shape S may formally be defined as the expected Euclidean distance ||β‹…|| between two random points x and y,[1]

𝔼[β€–xβˆ’yβ€–]=1Ξ»(S)2∫S∫Sβ€–xβˆ’yβ€–dΞ»(x)dΞ»(y)

where Ξ» is the n-dimensional Lebesgue measure.

For the two-dimensional case, this is defined using the distance formula for two points (x1, y1) and (x2, y2)

1Ξ»(S)2∬S∬S(x1βˆ’x2)2+(y1βˆ’y2)2dx1dy1dx2dy2.

Approximation methods

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.

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.

One such method is the Monte Carlo method. 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.

These methods can only give an approximation; they cannot be used to determine its exact value.

Formulas

Line segment

For a line segment of length Template:Math, the average distance between two points is Template:Math.[1]

Triangle

For a triangle with side lengths Template:Math, Template:Math, and Template:Math, the average distance between two points in its interior is given by the formula[2]

4ssasbsc15[1a3ln(ssa)+1b3ln(ssb)+1c3ln(ssc)]+a+b+c15+(b+c)(bβˆ’c)230a2+(a+c)(aβˆ’c)230b2+(a+b)(aβˆ’b)230c2,

where s=(a+b+c)/2 is the semiperimeter, and si denotes sβˆ’i.

For an equilateral triangle with side length a, this is equal to

(4+3ln320)aβ‰ˆ0.364791843…a.

Square and rectangles

The average distance between two points inside a square with side length s is[3]

(2+2+5ln(1+2)15)sβ‰ˆ0.521405433…s.

More generally, the mean line segment length of a rectangle with side lengths l and w is[1]

115[l3w2+w3l2+d(3βˆ’l2w2βˆ’w2l2)+52(w2lln(l+dw)+l2wln(w+dl))]

where d=l2+w2 is the length of the rectangle's diagonal.

If the two points are instead chosen to be on different sides of the square, the average distance is given by[3][4]

(2+2+5ln(1+2)9)sβ‰ˆ0.869009…s.

Cube and hypercubes

The average distance between points inside an n-dimensional unit hypercube is denoted as Template:Math, and is given as[5]

Ξ”(n)=∫01β‹―βˆ«01⏟2n(x1βˆ’y1)2+(x2βˆ’y2)2+β‹―+(xnβˆ’yn)2dx1β‹―dxndy1β‹―dyn

The first two values, Template:Math and Template:Math, refer to the unit line segment and unit square respectively.

For the three-dimensional case, the mean line segment length of a unit cube is also known as Robbins constant, named after David P. Robbins. This constant has a closed form,[6]

Ξ”(3)=4+172βˆ’63βˆ’7Ο€105+ln(1+2)5+2ln(2+3)5.

Its numerical value is approximately Template:Math Template:OEIS

Andersson et. al. (1976) showed that Template:Math satisfies the bounds[7]

13n1/2≀Δ(n)≀(16n)1/213[1+2(1βˆ’35n)1/2].

Choosing points from two different faces of the unit cube also gives a result with a closed form, given by,[4]

4+172βˆ’63βˆ’7Ο€75+7ln(1+2)25+14ln(2+3)25.

Circle and sphere

The average chord length between points on the circumference of a circle of radius r is[8]

4Ο€rβ‰ˆ1.273239544…r

And picking points on the surface of a sphere with radius r is [9]

43r

Disks

The average distance between points inside a disk of radius r is[10]

12845Ο€rβ‰ˆ0.905414787…r.

The values for a half disk and quarter disk are also known.[11]

For a half disk of radius 1:

6413512Ο€βˆ’23Ο€2β‰ˆ0.706053409…

For a quarter disk of radius 1:

32135Ο€2(6ln(22βˆ’2)βˆ’942+48Ο€+3)β‰ˆ0.473877262…

Balls

For a three-dimensional ball, this is

3635rβ‰ˆ1.028571428…r.

More generally, the mean line segment length of an n-ball is[1]

2n2n+1Ξ²nr

where Template:Math depends on the parity of Template:Math,

Ξ²n={23n+1(n/2)!2n!(n+1)(2n)!Ο€(for even n)2n+1n!3(n+1)((nβˆ’1)/2)!2(2n)!(for odd n)

General bounds

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]

L≀2nn+12nβˆ’2Ξ“(n/2)2Ξ“(nβˆ’1/2)Ο€

where Template:Math denotes the gamma function. For n = 2, a stronger bound exists.

L≀229800+44752βˆ’3+194805=0.678442…

References