In
geometry
Geometry (; ) is, with arithmetic, one of the oldest branches of mathematics. It is concerned with properties of space such as the distance, shape, size, and relative position of figures. A mathematician who works in the field of geometry is c ...
, 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
In mathematics, the Euclidean distance between two points in Euclidean space is the length of a line segment between the two points.
It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, therefor ...
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 expression
In mathematics, a closed-form expression is a mathematical expression that uses a finite number of standard operations. It may contain constants, variables, certain well-known operations (e.g., + − × ÷), and functions (e.g., ''n''th roo ...
s 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
.
Formal definition
The mean line segment length for an ''n''-
dimensional
In physics and mathematics, the dimension of a mathematical space (or object) is informally defined as the minimum number of coordinates needed to specify any point within it. Thus, a line has a dimension of one (1D) because only one coordi ...
shape ''S'' may formally be defined as the
expected Euclidean distance
In mathematics, the Euclidean distance between two points in Euclidean space is the length of a line segment between the two points.
It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, therefor ...
, , ⋅, , between two random points ''x'' and ''y'',
:
where ''λ'' is the ''n''-dimensional
Lebesgue measure
In measure theory, a branch of mathematics, the Lebesgue measure, named after French mathematician Henri Lebesgue, is the standard way of assigning a measure to subsets of ''n''-dimensional Euclidean space. For ''n'' = 1, 2, or 3, it coincides wit ...
.
For the
two-dimensional
In mathematics, a plane is a Euclidean (flat), two-dimensional surface that extends indefinitely. A plane is the two-dimensional analogue of a point (zero dimensions), a line (one dimension) and three-dimensional space. Planes can arise as s ...
case, this is defined using the
distance formula
In mathematics, the Euclidean distance between two points in Euclidean space is the length of a line segment between the two points.
It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, therefor ...
for two points (''x''
1, ''y''
1) and (''x''
2, ''y''
2)
:
Approximation methods
Since computing the mean line segment length involves calculating multidimensional integrals, various methods for
numerical integration
In analysis, numerical integration comprises a broad family of algorithms for calculating the numerical value of a definite integral, and by extension, the term is also sometimes used to describe the numerical solution of differential equations ...
can be used to approximate this value for any shape.
One such method is the
Monte Carlo method
Monte Carlo methods, or Monte Carlo experiments, are a broad class of computational algorithms that rely on repeated random sampling to obtain numerical results. The underlying concept is to use randomness to solve problems that might be determi ...
. 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 , the average distance between two points is .
Triangle
For a triangle with side lengths , , and , the average distance between two points in its interior is given by the formula
:
where
is the
semiperimeter
In geometry, the semiperimeter of a polygon is half its perimeter. Although it has such a simple derivation from the perimeter, the semiperimeter appears frequently enough in formulas for triangles and other figures that it is given a separate name ...
, and
denotes
.
For an equilateral triangle with side length ''a'', this is equal to
:
Square and rectangles
The average distance between two points inside a square with side length ''s'' is
:
More generally, the mean line segment length of a rectangle with side lengths ''l'' and ''w'' is
: