Square triangle picking is the independent uniform selection of triples of points (corresponding to vertices of a triangle)
inside a square. random triangles can be picked
in a unit square in the Wolfram
Language using the function RandomPoint[Rectangle[],
n,
3
].
Given three points chosen independently and uniformly inside a unit square, the average area of the triangle determined by these points is given analytically by the multiple integrals
|
(1)
| |||
|
(2)
|
Here,
represent the polygon vertices of the triangle
for
,
2, 3, and the (signed) area of these triangles
is given by the determinant
|
(3)
| |||
|
(4)
|
The solution was first given by Woolhouse (1867). Since attempting to do the integrals by brute force results in intractable integrands, the best approach using computer
algebra is to divide the six-dimensional region of integration into subregions
using cylindrical algebraic decomposition
such that the sign of does not change, do the integral
in each region directly, and then combine the results (Trott 1998). Depending on
the order in which the integration variables are ordered, between 32 and 4168 regions
are obtained. The result of combining these pieces gives the mean
triangle area
|
(5)
|
(Ambartzumian 1987, Pfiefer 1989, Trott 1998; Trott 2006, pp. 303-304).
Once
is known, the variance in area is easily calculated
by first computing the raw moment
,
|
(6)
| |||
|
(7)
|
giving
|
(8)
| |||
|
(9)
| |||
|
(10)
|
The area distribution was obtained by Henze (1983). For ,
the probability density function for
the area of a random triangle in the unit
square is given by
|
(11)
|
(M. Trott, pers. comm., Jan. 27, 2005; Trott 2006, p. 306). The probability density function is zero
outside .
The corresponding distribution function
is given by
|
(12)
|
(Philip). The distribution function is 0 for
and 1 for
.
satisfies the fourth-order ordinary
differential equation
|
(13)
|
(M. Trott, pers. comm., Jan. 27, 2005; Trott 2006, p. 307).
This gives the formula for raw moments as
|
(14)
|
where
is a harmonic number, so the raw
moments for
,
2, ... are 11/144, 1/96, 137/72000, 1/2400, 363/3512320, ... (OEIS A093158
and A093159).
A closed form is more difficult to compute for the th
central moment
, but the first few for
, 2, ... are 0, 95/20736, 75979/186624000, 1752451/17915904000,
... (OEIS A103281 and A103282;
Trott 2006, p. 307).
A closed form for the probability that a given point lies within a randomly picked triangle
can also be obtained as
|
(15)
|
where
|
(16)
|
(M. Trott, pers. comm., Jan. 31, 2005; Trott 2006, p. 310). This expression is valid for
and
,
with the expression for
given by symmetry as
|
(17)
|
On the boundary of the unit square, . As expected, this expression satisfies
|
(18)
|
Pick three points independently and uniformly in the unit square, and denote the probability that the three
points form an obtuse triangle by . Langford (1969) proved that
|
(19)
| |||
|
(20)
|
(OEIS A093072).
An invertible affine transformation takes the unit square to any parallelogram
and multiplies all areas by the same absolute
value of its determinant. It also preserves independent
uniform sampling after normalization. Thus, if a parallelogram
has area and
is the area of a triangle
formed by three independent uniform points,
has the same distribution
function as
.
In particular,
|
(21)
| |||
|
(22)
| |||
|
(23)
|
The reduction applies to parallelograms, since they are precisely the affine images of a square. It does not reduce an arbitrary convex quadrilateral to the square case.