Probability moments for ellipse and rectangle

Let K be a finite plane convex region. In working out the expected number of alignments in a random set of points, with independent uniform distributions in K, we need the moments of the p.d.f. for |P1P2|, the distance between two points P1 and P2 with independent uniform distributions in K. Denote by Mn the nth moment, i.e. the mean value of |P1P2|n.

With a strip criterion, the expected number of r-point alignments (r3) typically depends on Mr2, so that all positive moments are needed. With an angle criterion, the expected number of r-point alignments typically depends on M2r4, so that only even moments are needed. In the formulae below, the form of Mn differs for odd and even n.

The lists below give the first few values of Mn for K = ellipse and rectangle, with circle and square listed separately for convenience. There is then a description of how the moments can be calculated for these K.


For a circle with radius a :

M1=  128a
M2= a2
M3=  2048a3
M4=  5a4
M5=  16384a5
M6=  7a6


For an ellipse with semi-major axis a and eccentricity e :

Here K(e) and E(e) are complete elliptic integrals (see below).

M1  =  256a E(e)
M1  =  128a ( 1  1 e2  3 e4  5 e6  175 e8  441 e10 )
45π 4 64 256 16384 65536
M2  =  ( 1  1 e2 )
M3  =  4096a3 ( (42e2)E(e)(1e2)K(e) )
M3  =  2048a3 ( 1  3 e2+  9 e4+  5 e6+  105 e8+  189 e10+ )
525π 4 64 256 16384 65536
M4  =  5a4 ( 1  e2+  3 e4 )
3 8
M5  =  32768a3 ( (2323e2+8e4)E(e)4(1e2)(2e2)K(e) )
M5  =  16384a5 ( 1  5 e2+  45 e4  25 e6  175 e8  189 e10 )
2205π 4 64 256 16384 65536
M6  =  7a6 ( 1  3 e2+  9 e4  5 e6 )
2 2 8 16


For a square with side a:

M1=  a ( 2+2+5ln(2+1) )
M2=  a2
M3=  a3 ( 8+172+21ln(2+1) )
M4=  17a4
M5=  a5 ( 16+732+45ln(2+1) )
M6=  29a6


For a rectangle with sides a and b:

Let d=(a2+b2), and let

Ln=  an+1 ln ( d+b ) +  bn+1 ln ( d+a )
b a a b


M1=  1 ( 10d  2(d5a5b5)  +5L1 )
30 a2b2
M2=  1 d2
M3=  1 ( 49d3  8(d7a7b7)  +21L3 )
420 a2b2
M4=  1 ( 6a4+5a2b2+6b4 )
M5=  1 ( 3d (41a4+52a2b2+41b4)  16(d9a9b9)  +45L5 )
2016 a2b2
M6=  1 ( 15a6+14a4b2+14a2b4+15a6 )

A theorem of Santaló

A theorem given by Santaló [Ref. 1] is useful in calculating the moments.

Distance between two random points in a convex set Notation defining position of a chord in a convex set

Let P1P2=r. Santaló defines

Jn=    rndP1dP2.
P1 ,P2K

Let G be a variable line defined by coordinates (p,φ) (Fig. 1b), and if G meets K let σ be the length of the chord so defined. Santaló defines

In=    σndG,

which we may write as

In=   ∫ σndpdφ ,
p=0 φ=0

taking σ=0 if G does not meet K. Santaló proves that

Jn=  2 In+3.

Now let |K| be the area of K and let Mn be the nth moment of the p.d.f. of r. Clearly

Mn=  Jn

and consequently

Mn=  2 In+3 .
(n+2)(n+3) |K|2

It may be easier to evaluate In+3 and apply this formula, than to evaluate Mn directly.

Moments for an ellipse

Notation defining position of a chord in an ellipse

We evaluate Mn for an ellipse from Santaló’s In+3, as above.

Let the equation of the ellipse be x2/a2+y2/b2=1, and let e be the eccentricity, so that b2=a2(1e2). Setting


we find by a routine calculation that the line (p,φ) meets the ellipse iff |p|q(φ), and then

σ=2abq(φ)2 (q(φ)2p2)1/2.

Putting p = q(φ)sinθ gives

In=  π/2  ∫  [2abq(φ)2]n [q(φ)cosθ]n+1dθdφ = 2nCn+1abn π/2  (1e2sin2φ)−(n1)/2,
θ=0 φ=0 0


Cm=  π/2 cosmθdθ ,so that C0=π/2, C1=1, Cm=Cm2(m1)/m  (m=2,3,…).

Combining, and noting that the integral from 0 to is 4 times the integral from 0 to π/2, we get

Mn=  2n+6Cn+4 bn+1 π/2  (1e2sin2φ)−(n+2)/2dφ.
(n+2)(n+3) π2a 0

The integral here (call it An) can be done for a particular e by numerical integration. Alternatively, it can be solved explicitly as follows. To bring An into the form tabulated by Gradshteyn & Ryzhik [Ref. 2], define

θ=π,c=(1e2)1/2, ƒ=  1c .


An=  π/2  (1e2sin2φ)−(n+2)/2=2n+1(1c)−(n+2) π  (1co+ƒ2)−(n+2)/2.
0 0

Case of even n.  Let n=2m. From item 3.616.2 of [Ref. 2],

An=2n+1(1+c)−(n+2)×π(1ƒ2)−(m+1) m (m+k)! uk,
k=0 k!2(mk)!

where u=ƒ2/(1ƒ2)=(1c)2/4c. Simplifying slightly,

An=π(2c)−(2m+1) m (m+k)! (1c)2k(4c)mk.
k=0 k!2(mk)!

One checks empirically (I have no proof yet) that

m (m+k)! (1c)2k(4c)mk=  m (2k)! (2m2k)! c2k=  m (2k)!m! 4mk(−e2)k.
k=0 k!2(mk)! k=0 k!2 (mk)!2 k=0 k!3(mk)!

For even n=2m we conclude

Mn=  2n+4 n+1 n1 1 an m (2k)!m! (−e2/4)k,
(n+2)(n+4) n+2 n 2 k=0 k!3(mk)!

where for a circle (e = 0) the sum equals 1.

Case of odd n.  Let n = 2m – 1. From item 3.617 of [Ref. 2],

An=  2n+1 2 Fm ( 1/2 ) ,
(1+c)n+2 (1+ƒ)n+2 1+ƒ

where the functions Fm are defined below. Since (1+c)(1+ƒ)=2 and 1/2(1+ƒ)=e, we have

Mn=  2n+6Cn+4 an  (1e2)mFm(e) .
(n+2)(n+3) π2

We now define the Fm as in [Ref. 2]. F0 is the complete elliptic integral of the first kind, given by

F0(e)= K(e)=  π/2 (1e2sin2θ)1/2dθ=  π ( 1+  12 e2+  1232 e4+  123252 e6+ )
0 2 22 2242 224262

and the Fm satisfy the recurrence relation

Fm+1(e)=Fm(e)+  e dFm(e)  (m=0,1,2,…).
2m+1 de

In our case it is convenient to define Gm(e)=(2/π)(1e2)mFm(e). The recurrence relation for the Gm is

Gm+1(e)=Gm(e)+  1 ( e(1e2) dGm(e)  e2Gm(e) )  (m=0,1,2,…).
2m+1 de

If we introduce as in [Ref. 2] the complete elliptic integral of the second kind, given by

E(e)=  π/2 (1e2sin2θ)1/2dθ=  π ( 1  1 e2  123 e4  12325 e6 )
0 2 22 2242 224262

then the derivatives

dK(e)  =  E(e)    K(e)  ,   dE(e)  =  E(e) K(e) ,
de e(1e2) e de e

combined with the recurrence relation for Fm, lead to

G1(e)=  2 (1e2) F1(e)=  2 E(e) ,
π π
G2(e)=  2 (1e2)2F2(e)=  2 ( (42e2)E(e)(1e2)K(e) ) ,
π 3π
G3(e)=  2 (1e2)3F3(e)=  2 ( (2323e2+8e4)E(e)4(1e2)(2e2)K(e) ) ,
π 15π

and so on (the working becomes laborious). Alternatively, the recurrence relation for Gm leads to

Gm(e)=1  1 (2m1)e2+  1.3 (2m1)(2m3)e4  135 (2m1)(2m3)(2m5)e6+… .
22 2242 224262

For odd n=2m1 we conclude

Mn=  2n+4 n+1 n1  …  2 2 anGm(e) ,
(n+2)(n+4) n+2 n 3 π

where for a circle Gm(0) = 1.

It is possible to combine the results for even and odd n into a single formula, but this is less convenient for applications.

Moments for a rectangle

Notation defining position of a chord in a rectangle

We evaluate Mn for a rectangle from Santaló’s In+3, as above.

Let the diagonal of the rectangle be d, and let the sides be a=dco, b=dsi. It suffices to consider 0φπ/2.

First suppose 0φπ/2γ. Define p1=(d/2)cos(γ+φ) , p2=(d/2)cos(γφ)S. The chord length σ for the line (p,φ) is given by

σ=bsecφ if  0pp1
σ=bse×(p2p)/(p2p1) if  p1pp2
0 if  p>p2

from which we easily find

σndp=(dsinγ secφ)n ( dcos(γ+φ)  +  dsinγ si ) .
0 2 n+1

Similarly, for π/2γφπ/2 we find

σndp=(dcosγ cosecφ)n ( −  dcos(γ+φ)  +  dcosγ co ) ,
0 2 n+1

which has the same form as the first integral if we put  γ=π/2γ′φ=π/2φ′.

Integrating over φ=0 to we find for n>0 that

In=2dn+1sinnγ co π/2γ secn1φdφ  2 dn+1(sin2γsinn+1γ)+ comp,
0 n+1

where “comp” is obtained by putting π/2γ in place of γ. Recall that if

Sm(θ)=  θ secmφdφ

for 0θπ/2 and integer m>0, then

Sm(θ)=  1 tanθ secm2θ+  m2 Sm2(θ) (m=3,4,…).
m1 m1

Hence if we define

U2=  d ln ( d+b ) ,U3=1,Um=  1  +  m3 a2 Um2,
b a m2 m2 d2
V2=  d ln ( d+a ) ,V3=1,Vm=  1  +  m3 b2 Vm2,
a b m2 m2 d2

then the moments Mn are given by

Mn=  4 ( dn (Un+3+Vn+3  dn+4an+4bn+4 ) .
(n+2)(n+3) (n+4)a2b2

For even n this expression reduces to a polynomial in a2,b2. Putting n=2m we have

M2m=m! m a2(mk)b2k .
k=0 (2k+1) (2m2k+1) (k+1)! (mk+1)!

There does not seem to be a similar result for odd n.


[1] Luis A. Santaló, Integral Geometry and Geometric Probability (Vol. 1 of Encyclopedia of Mathematics and its Applications), Addison-Wesley, 1976, pp. 45–49.
[2] I.S. Gradshteyn & I.M. Ryzhik, Table of Integrals, Series, and Products, 6th edn, Addison-Wesley, 2000, pp. 387–388.