numerical methods for special functions || 10. inversion of cumulative distribution functions

22
0.1 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.9 0.8 0 0 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1 Chapter 10 Inversion of Cumulative Distribution Functions We are not certain, we are never certain. If we were we could reach some conclusions, and we could, at last, make others take us seriously. Albert Camus, French philosopher and writer 10.1 Introduction The inversion of cumulative distribution functions is an important topic in statistics, proba- bility theory, and econometrics, in particular for computing percentage points of chi-square, F , and Student’s t -distributions. In the tails of these distributions the numerical inversion is not very easy, and for the standard distributions asymptotic formulas are available. In this chapter we use the uniform asymptotic expansions of the incomplete gamma functions and incomplete beta functions, which are the basic functions for several distribu- tion functions, for inverting these functions for large values of one or two parameters. The methods have been developed in [216, 217], and we summarize the main parts of these pa- pers. For algorithms, including Fortran subroutines, for computing the incomplete gamma function ratios and their inverse, we refer to [55, 56]. We start with the relatively simple problem of inverting the complementary error function, again by using asymptotic methods. In a final section we consider the inversion of the incomplete gamma function P(a, x) for small values of a by using a high order Newton-like method. 10.2 Asymptotic inversion of the complementary error function We recall the definition of the complementary error function (we use here real arguments) erfc x = 2 π x e t 2 dt (10.1) 309 Downloaded 07/05/14 to 128.6.218.72. Redistribution subject to SIAM license or copyright; see http://www.siam.org/journals/ojsa.php

Upload: nico-m

Post on 14-Feb-2017

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

0.1

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.9

0.8

00 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

1

1

Chapter 10

Inversion ofCumulativeDistributionFunctions

We are not certain, we are never certain. If we were we couldreach some conclusions, and we could, at last, make otherstake us seriously.—Albert Camus, French philosopher and writer

10.1 IntroductionThe inversion of cumulative distribution functions is an important topic in statistics, proba-bility theory, and econometrics, in particular for computing percentage points of chi-square,F , and Student’s t-distributions. In the tails of these distributions the numerical inversionis not very easy, and for the standard distributions asymptotic formulas are available.

In this chapter we use the uniform asymptotic expansions of the incomplete gammafunctions and incomplete beta functions, which are the basic functions for several distribu-tion functions, for inverting these functions for large values of one or two parameters. Themethods have been developed in [216, 217], and we summarize the main parts of these pa-pers. For algorithms, including Fortran subroutines, for computing the incomplete gammafunction ratios and their inverse, we refer to [55, 56].

We start with the relatively simple problem of inverting the complementary errorfunction, again by using asymptotic methods.

In a final section we consider the inversion of the incomplete gamma function P(a, x)for small values of a by using a high order Newton-like method.

10.2 Asymptotic inversion of the complementary errorfunction

We recall the definition of the complementary error function (we use here real arguments)

erfc x = 2√π

∫ ∞

x

e−t2dt (10.1)

309

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 2: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

310 Chapter 10. Inversion of Cumulative Distribution Functions

and the asymptotic expansion

erfc x ∼ e−x2

x√π

∞∑k=0

(−1)k(2k)!k! (2x)2k = e−x2

x√π

(1− 1

2x−2 + 3

4x−4 − 15

8x−6 + · · ·

), (10.2)

as x→∞.We derive an asymptotic expansion for the inverse x(y) of the function y(x) = erfc x

for small positive values of y.Let t, α, and β be defined by

t = 2

πy2, α = 1

ln t, β = ln(ln t). (10.3)

Then we have the expansion

x(y) ∼ 1√2α

(1+ x1α+ x2α

2 + x3α3 + x4α

4 + · · ·) . (10.4)

The first coefficients xk are given by

x1 = − 12β,

x2 = − 18

(β2 − 4β + 8

),

x3 = − 116

(β3 − 8β2 + 32β − 56

),

x4 = − 1384

(15β4 − 184β3 + 1152β2 − 4128β + 7040

),

x5 = − 1768

(21β5 − 352β4 + 3056β3 − 16752β2 + 57536β − 97984

).

(10.5)

We explain how these coefficients can be obtained. The equation y = erfc x, withy small, will be solved for x by using the asymptotic expansion in (10.2). We square theequation and write

1

2πy2 = e

−ξ

ξS2(ξ), (10.6)

where ξ = 2x2 and S(ξ) denotes the function that has the power series in (10.2) as itsasymptotic expansion with 2x2 replaced by ξ.

We can rewrite (10.6) in the form

ξ eξ = t S2(ξ), (10.7)

where t is defined in (10.3). We solve this equation for ξ, with t large.We observe that this equation has been discussed in detail in [50, §2.4] for the case

that S(ξ) = 1. We can apply the same method for constructing an asymptotic expansion ofthe equation in (10.7). We write

ξ = ln t − ln(ln t)+ η (10.8)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 3: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

10.2. Asymptotic inversion of the complementary error function 311

Table 10.1. Solutions x(y) of the equation y = erfc x by using (10.4) .

y x̃ |erfc(x̃)/y − 1| x̂ |x̃/x̂− 1|10−02 1.820630554 0.31 10−02 1.821591563 0.53 10−03

10−03 2.326648925 0.51 10−03 2.326782380 0.57 10−04

10−04 2.751038248 0.15 10−03 2.751070914 0.12 10−04

10−05 3.123404718 0.56 10−04 3.123415612 0.35 10−05

10−06 3.458907270 0.25 10−04 3.458911685 0.13 10−05

10−07 3.766560973 0.13 10−04 3.766563021 0.54 10−06

10−08 4.052236421 0.69 10−05 4.052237469 0.26 10−06

10−09 4.320004932 0.41 10−05 4.320005509 0.14 10−06

10−10 4.572824704 0.25 10−05 4.572825039 0.74 10−07

and find that η satisfies the relation

(ln t − ln(ln t)+ η) eη = ln t S2(ln t − ln(ln t)+ η). (10.9)

The quantity η can be expanded in the form

η = η1 α+ η2 α2 + η3 α

3 + · · · , (10.10)

where α is defined in (10.3). By using a few terms in the expansion of S(ξ) we find

η1 = β − 2, η2 = 12β

2 − 3β + 7, (10.11)

where β is defined in (10.3).The expansion for η gives an expansion for ξ (see (10.8)), and by using x = √ξ/2 we

obtain the expansion given in (10.4).In Table 10.1 we give values of the approximation x̃ of the solution of the equation

y = erfc x for several values of y. We have used the asymptotic expansion (10.4) with theterms up to and including x4. The values x̂ are obtained by using one Newton–Raphsonstep. We also give relative errors. The computations are done in Maple with default 10-digitarithmetic.

For other methods of the inversion of the error functions, we refer to [203], wherecoefficients of the Maclaurin expansion of x(y), the inverse of y = erf x, are given, withChebyshev coefficients for an expansion on the y-interval [−0.8, 0.8]. For small values ofy (not smaller than 10−300) high-precision coefficients of Chebyshev expansions are givenfor the numerical evaluation of the inverse of y = erfc x. For rational Chebyshev (near-minimax) approximations for the inverse of the complementary error function y = erfc x,we refer to [15], where y-values are considered in the y-interval [10−10000, 1], with relativeerrors ranging down to 10−23. An asymptotic formula for the region y→ 0 is also given.

Remark 15. In Chapter 7, §7.6.3, we use similar asymptotic inversion methods for findingcomplex zeros of the error function. The present case is simpler because we want to findonly one real solution with the inversion method.

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 4: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

312 Chapter 10. Inversion of Cumulative Distribution Functions

Remark 16. The solution of the equation ξeξ = t (see (10.7)) can be expressed in termsof Lambert’sW -function: ξ = W(t).

10.3 Asymptotic inversion of incomplete gammafunctions

We solve the equations

P(a, x) = p, Q(a, x) = q, 0 ≤ p ≤ 1, 0 ≤ q ≤ 1, (10.12)

where P(a, x) and Q(a, x) are the incomplete gamma functions introduced in (8.12) in§8.3. We invert the equations for x, with a as a large positive parameter. This problemis of importance in probability theory and mathematical statistics. Several approaches areavailable in the (statistical) literature, where often a first approximation of x is constructed,based on asymptotic expansions, but this first approximation is not always reliable. Higherapproximations may be obtained by numerical inversion techniques, which require evalu-ation of the incomplete gamma functions. This may be rather time consuming, especiallywhen a is large.

In the present method we also use an asymptotic result. The approximation is quiteaccurate, especially when a is large. It follows from numerical results, however, that athree-term asymptotic expansion already gives an accuracy of 4 significant digits for a = 2,uniformly with respect to p, q ∈ [0, 1].

The method is rather general. In a later section we mention application of the samemethod on a wider class of cumulative distribution functions.

The approximations are obtained by using the uniform asymptotic expansions of theincomplete gamma functions given in §8.3, in which an error function is the dominant term.The inversion problem is started by inverting this error function term.

In §10.6 we consider the inversion of P(a, x) for small values of a.

10.3.1 The asymptotic inversion method

We perform the inversion of (10.12) with respect to the parameter η by using the represen-tations (8.17), with z replaced by x throughout, and large positive values of a. Afterwardswe have to compute λ and x from the relation for η in (8.18) and λ = x/a. We concentrateon the second equation in (10.12). Let us rewrite the inversion problem in the form

12 erfc

(η√a/2

)+ Ra(η) = q, q ∈ [0, 1], (10.13)

which is equivalent to the second equation in (10.12), and we denote the solution of theabove equation by η(q, a).

To start the procedure we consider Ra(η) in (10.13) as a perturbation, and we definethe number η0 = η0(q, a) as the real number that satisfies the equation

12 erfc

(η0

√a/2

)= q. (10.14)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 5: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

10.3. Asymptotic inversion of incomplete gamma functions 313

Known values are

η0(0, a) = +∞, η0

(12 , a

)= 0, η0(1, a) = −∞. (10.15)

We note the symmetry η0(q, a) = −η0(p, a). Computation of η0 requires an inversion ofthe error function, but this problem has been satisfactorily solved in the literature; see §10.2.The value η defined by (10.13) is, for large values of a, approximated by the value η0. Wewrite

η(q, a) = η0(q, a)+ ε(η0, a), (10.16)

and we try to determine the function ε. It appears that we can expand this quantity in theform

ε(η0, a) ∼ ε1

a+ ε2

a2+ ε3

a3+ · · · , (10.17)

as a→∞. The coefficients εi will be written explicitly as functions of η0.We first remark that (10.13) yields the relation

dq

dη= d

dηQ(a, x) = d

dxQ(a, x)

dx

dη. (10.18)

Using the definition ofQ(a, x) and the relation forη in (8.18), we obtain after straightforwardcalculations

dq

dη= − 1

�∗(a)

√a

2πf(η)e−

12 aη

2, (10.19)

where �∗(a) is defined in (8.28), and

f(η) = η

λ− 1, (10.20)

the relation between η and λ being given in (8.18). For small values of η we can expand

f(η) = 1− 13η+ 1

12η2 + · · · . (10.21)

From (10.14) we obtaindq

dη0= −

√a

2πe−

12 aη

20 . (10.22)

Upon dividing (10.19) and (10.22), we eliminate q, although it is still present in η0. So weobtain

dη0= �

∗(a)f(η)

e12 a(η

2−η20), −∞ < η0 <∞. (10.23)

Substitution of (10.16) gives the differential equation

f(η0 + ε)[

1+ dε

dη0

]= �∗(a)eaε(η0+ 1

2 ε), (10.24)

a relation between ε and η0, with a as (large) parameter.

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 6: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

314 Chapter 10. Inversion of Cumulative Distribution Functions

It is convenient to write η in place of η0. That is, we try to find the function ε = ε(η, a)that satisfies the equation

f(η+ ε)[

1+ dεdη

]= �∗(a)eaε(η+ 1

2 ε). (10.25)

When we have obtained the solution ε(η, a) (in fact we find an approximation of the form(10.17)), we write it as ε(η0, a), and the final value ofη follows from (10.16). The parametersλ and x of the incomplete gamma function then follow from inversion of the relation for ηin (8.18).

10.3.2 Determination of the coefficients εi

For large values of a we have �∗(a) = 1+O(a−1); see (8.31). Comparing dominant termsin (10.25), we infer that the first coefficient ε1 in (10.17) is defined by

f(η) = eηε1 , (10.26)

giving

ε1 = 1

ηln f(η). (10.27)

It is not difficult to verify that f is positive on R, f(0) = 1, and that f is analytic in aneighborhood of η = 0. It follows that ε1 = ε1(η) is an analytic function on R. For smallvalues of η we have, using (10.21),

ε1 = − 13 + 1

36η+ 11620η

2 + · · · . (10.28)

The function ε1(η) is nonvanishing on R (and hence negative). To show this, considerthe equation f 2(η) = 1. From (10.20) and the relation for η in (8.18), it follows that thecorresponding λ-value should satisfy

− ln λ = (λ− 1)(2λ− 3). (10.29)

This equation has only one real solution, λ = 1, which gives η = 0. However, for this valueε1 equals − 1

3 .Further coefficients in (10.17) can be obtained by using standard perturbation methods.

We need the expansion of �∗(a) given in (8.29), and

f(η+ ε) = f(η)+ εf ′(η)+ 12ε

2f ′′(η)+ · · · , (10.30)

in which (10.17) is substituted to obtain an expansion in powers of a−1. Putting all this into(10.25), we find by comparing terms with equal powers of a−1,

ε2 = 1

12ηf(12fε′1 + 12f ′ε1 − f − 6fε2

1) (10.31)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 7: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

10.3. Asymptotic inversion of incomplete gamma functions 315

and

ε3 = 1

288ηf(288fε′2 + 288f ′ε1ε

′1 − 24fε′1 + 288f ′ε2 + 144f ′′ε2

1

− 24f ′ε1 + f − 288fε1ε2 − 144fε22η

2 − 144fε2ηε21 − 36fε4

1).

(10.32)

The derivatives f ′ and ε′j are with respect to η. It will be obvious that the complexityfor obtaining higher order terms is considerable. The terms shown so far have been ob-tained by symbolic manipulation. For numerical evaluations it is very convenient to haverepresentations free of derivatives.

The derivatives of f can be eliminated by using

f ′ = f(1− f 2 − fη)/η,f ′′ = f 2(−3η− 3f + 3f 3 + 5f 2η+ 2η2f)/η2,

(10.33)

and so on.The first relation easily follows from (10.20) and the relation between η and λ. Using

these relations in εi, and eliminating the derivatives of previous εj , it follows that we canwrite η2j−1εj as a polynomial in η, f, ε1. We have

12η3ε2 = 12− 12f 2 − 12fη− 12f 2ηε1 − 12fη2ε1 − η2 − 6η2ε21,

12η5ε3 = −30+ 12f 2ηε1 + 12fη2ε1 + 24f 2η3ε1 + 6ε31η

3 + 60f 3η2ε1

−12f 2 + 31f 2η2 + 72f 3η+ 42f 4 + 18f 3η3ε21 + 6f 2η4ε2

1 + 36f 4ηε1

+12ε21η

3f + 12ε21η

2f 2 − 12ηε1 + η3ε1 + fη3 − 12fη+ 12ε21η

2f 4.

(10.34)

From these representations we can conclude that the coefficients ε1, ε2, ε3 are boundedon R. To show this we need

f(η) ∼ −η, η→−∞, f(η) ∼ 2η−1, η→+∞, (10.35)

and the above representations of εi. We find

ε1 ∼ ∓ ln |η|η, ε2 ∼ − 1

12η, ε3 ∼ ε1

12η2, (10.36)

as η → ±∞. In deriving the behavior at −∞ one should take into account (see (10.20)and the relation between η and λ) that

f(η)+ η = λη

λ− 1∼ −ηe− 1

2 η2, η→−∞. (10.37)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 8: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

316 Chapter 10. Inversion of Cumulative Distribution Functions

10.3.3 Expansions of the coefficients εi

As explained in §8.3, the function f is analytic in a strip |�η| < √2π, and it can be expandedin a Taylor series at the origin with radius of convergence 2

√π. All εi have similar analytic

properties. That is, the coefficients εi can be expanded in series form,

εi =∞∑n=0

ci,nηn, |η| < 2

√π, i = 1, 2, 3, . . . . (10.38)

The representations of εi given in the previous section are not suitable for numerical com-putations. To facilitate numerical evaluations of ε1, . . . , ε4 we provide for small valuesof η the following Taylor expansions (more details on the coefficient ε4 are given in [216]):

ε1 = − 13 + 1

36η+ 11620η

2 − 76480η

3 + 518144η

4 − 11382725η

5 + · · · ,ε2 = − 7

405 − 72592η+ 533

204120η2 − 1579

2099520η3 + 109

1749600η4 + · · · ,

ε3 = 449102060 − 63149

20995200η+ 2923336741600η

2 + 3467935290790400η

3 + · · · ,ε4 = 319

183708 − 2693834232632320η− 449882243

982102968000η2 + · · · .

(10.39)

10.3.4 Numerical examples

When p = q = 12 , the asymptotics are quite simple. Then η0 of (10.14) equals zero, and

from (10.39), we obtain (10.16) and (10.17) in the form

η ∼ − 13a−1 − 7

405a−2 + 449

102060a−3 + 319

183708a−4 + · · · . (10.40)

In this case we give an expansion of the requested value x. Recall that x = aλ and that λ canbe obtained from the relation between η and λ in (8.18) with η given by (10.40). Inverting

12η

2 = 12 (λ− 1)2 − 1

3 (λ− 1)3 + 14 (λ− 1)4 + · · · , (10.41)

we obtainλ = 1+ η+ 1

3η2 + 1

36η3 − 1

270η4 + 1

4320η5 + · · · . (10.42)

Substituting (10.40), we have

x ∼ a(

1− 13a−1 + 8

405a−2 + 184

25515a−3 + 2248

3444525a−4 + · · ·

). (10.43)

When a = 1, q = 12 , the equations in (10.12) reduce to e−x = 1

2 , with solution x = ln 2 =0.693147 . . . , while expansion (10.43) gives x ∼ 0.694 . . . , an accuracy of about 3 digits.When a = 2, q = 1

2 , the equations in (10.12) become (1 + x)e−x = 12 , with solution

x = 1.6783469 . . . ; in this case our expansion (10.40) gives x ∼ 1.67842 . . . , an accuracyof 4 significant digits. This shows that (10.40) is quite accurate for small values of the(large) parameter a. Computer experiments show that for other q-values the results are ofthe same kind. See Table 10.2.

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 9: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

10.4. Generalizations 317

Table 10.2. Relative errors |xa − x|/x and |Q(a, xa)− q|/q for several values ofq and a; xa is obtained by using asymptotic expansion (10.17); x is a more accurate value.

a

q 1 5 10

0.0001 2.3 10−4 2.1 10−3 1.1 10−6 1.6 10−5 9.4 10−8 1.7 10−6

0.1 6.6 10−4 1.5 10−3 2.0 10−6 9.3 10−6 1.4 10−7 8.8 10−7

0.3 8.7 10−4 1.0 10−3 2.3 10−6 6.4 10−6 1.6 10−7 6.0 10−7

0.5 7.0 10−4 4.8 10−4 6.7 10−7 1.2 10−6 5.4 10−8 1.4 10−7

0.7 4.9 10−4 1.7 10−4 2.7 10−6 2.6 10−6 1.7 10−7 2.6 10−7

0.9 1.9 10−3 2.0 10−4 2.5 10−6 8.8 10−7 1.8 10−7 9.3 10−8

0.9999 5.1 10−3 5.1 10−7 3.9 10−6 1.8 10−9 6.0 10−8 4.8 10−11

In a second example we take a = 2, q = 0.1; inverting (10.14) we obtain η0 =0.9061938. Using (10.17) we compute

η ∼ η0 − 0.308292/2− 0.0180893/4+ 0.0023105/8 = 0.747814. (10.44)

An inversion of the relation between η and λ gives λ = 1.944743, and hence x = 2λ =3.889486. Computing Q(2, x) with this value of x gives 0.1000186, an accuracy of 4digits. A more accurate value of x can be obtained by a Newton–Raphson method, givingx = 3.8897202. It follows that this value of x obtained by the asymptotic method (witha = 2) is accurate within 4 significant digits.

In Table 10.2 we give more results of numerical experiments. We have used (10.17)with three terms. The first column, under each a-value, gives the relative accuracy |xa−x|/x,where xa is the result of the asymptotic method, and x is a more accurate value obtainedby a Newton–Raphson method. The second column, under each a-value, gives the relativeerrors |Q(a, xa)− q|/q.

10.4 GeneralizationsThe method described in the previous sections can be applied to other cumulative distributionfunctions. Consider the function

Fa(η) =√a

∫ η

−∞e−

12 aζ

2f(ζ) dζ, (10.45)

where a > 0 and η ∈ R. We assume that f is an analytic function in a domain containingthe real axis, and that f is positive on R with the normalization f(0) = 1. In [211] it isshown that several well-known distribution functions can be written in this form, includingthe incomplete gamma and beta functions. It is also shown that the following representationholds:

Fa(η) = 12 erfc

(−η√a/2)Fa(∞)+ Ra(η), (10.46)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 10: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

318 Chapter 10. Inversion of Cumulative Distribution Functions

where Ra(η) can be expanded as in (8.19). Fa(∞) is the complete integral and can beexpanded in the form

Fa(∞) ∼∞∑n=0

An

an, as a→∞, A0 = 1. (10.47)

By dividing both sides of (10.45) by Fa(∞), we obtain a further normalization, which istypical for distribution functions.

The inversion of the equation Fa(η)/Fa(∞) = q, with q ∈ [0, 1] and a a given (large)number, can be performed as in the case of the incomplete gamma functions. As in (10.14),let η0 be the real number satisfying the equation

12 erfc

(−η0

√a/2

)= q. (10.48)

Then the requested value η is written as in (10.16), and an expansion like (10.17) can beobtained by deriving the differential equation (10.24), with f of (10.45) and �∗(a) replacedby Fa(∞).

In the next section we consider the incomplete beta function, for which three differentinversion cases are discussed.

10.5 Asymptotic inversion of the incomplete betafunction

The incomplete beta function is defined by

Ix(a, b) = 1

B(a, b)

∫ x

0ta−1(1− t)b−1 dt, a > 0, b > 0, (10.49)

where B(a, b) is Euler’s beta integral

B(a, b) =∫ 1

0ta−1(1− t)b−1 dt = �(a)�(b)

�(a+ b) . (10.50)

The incomplete beta function is a standard probability function, with as special casesthe (negative) binomial distribution, Student’s t-distribution, and the F -(variance-ratio)distribution.

We consider the following inversion problem. Let p ∈ [0, 1] be given. We areinterested in the x-value that solves the equation

Ix(a, b) = p, (10.51)

where a and b are fixed positive numbers. We are especially interested in solving (10.51)for large values of a and b.

The method for the asymptotic inversion is the same as that for the incomplete gammafunctions. The present problem is more difficult, of course, since now two large parametersare considered. In fact we consider three asymptotic representations of the incomplete beta

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 11: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

10.5. Asymptotic inversion of the incomplete beta function 319

function with a+ b→∞, valid in the following cases:

• a = b+ β, where β stays fixed;

• a/b and b/a are bounded away from zero;

• at least one of the parameters a, b is large.

In the first two cases both parameters are large; in the third case we allow one parameterto be fixed or substantially smaller than the other one. In the first two cases the underlyingbeta distribution can be approximated by a normal (Gaussian) distribution, and we use anerror function as the main approximant. In the third case the distribution may be quiteskewed, and we consider an approximation in terms of the gamma distribution, with anincomplete gamma function as the main approximant. It is possible to restrict ourselves toa ≥ b, since we have the relation

Ix(a, b) = 1− I1−x(b, a). (10.52)

This relation is used in the third case, where the only condition is that the sum a+ b shouldbe large.

10.5.1 The nearly symmetric case

We write b = a+ β, where β is fixed. We obtain from (10.49)

Ix(a, a+ β) = 4−a

B(a, a+ β)∫ x

0[4t(1− t)]a (1− t)

β dt

t(1− t) . (10.53)

We transform this into a standard form with a Gaussian character by writing

− 12ζ

2 = ln[4t(1− t)], 0 < t < 1, sign(ζ) = sign(t − 1

2

),

− 12η

2 = ln[4x(1− x)], 0 < x < 1, sign(η) = sign(x− 1

2

).

(10.54)

This gives

Ix(a, a+ β) = 4−a

B(a, a+ β)∫ η

−∞e−

12 aζ

2 (1− t)βt(1− t)

dt

dζdζ. (10.55)

We can write t as a function of ζ,

t = 12

[1±

√1− exp(− 1

2ζ2)

]= 1

2

[1+ ζ

√[1− exp(− 1

2ζ2)]/ζ2

], (10.56)

where the second square root is nonnegative for real values of the argument. The samerelation holds for x as a function of η. It easily follows that

1

t(1− t)dt

dζ= −ζ

1− 2t, (10.57)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 12: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

320 Chapter 10. Inversion of Cumulative Distribution Functions

and that the following standard form (in the sense of §10.4) is obtained:

Ix(a, a+ β) =√a

∫ η

−∞e−

12 aζ

2f(ζ) dζ, (10.58)

withf(ζ) = �(a)φ(ζ), (10.59)

where

�(a) = 1√a

�(a+ 12β)

�(a)

�(a+ 12β + 1

2 )

�(a+ β) ,

φ(ζ) = [2(1− t)]β√

σ

1− exp(−σ) , σ = 1

2ζ2.

(10.60)

This form of �(a) is obtained by using the duplication formula of the gamma function:

√π�(2z) = 22z−1�(z)�

(z+ 1

2

). (10.61)

From the asymptotic expansion of the ratio of gamma functions (see, for instance, [2,eq. (6.1.47)]), we obtain

�(a) ∼ c0 + c1a−1 + c2a

−2 + · · · , a→∞, (10.62)

where

c0 = 1, c1 = 18 (−2β2 + 2β − 1), c2 = 1

128 (4β4 + 8β3 − 16β2 + 4β + 1). (10.63)

The function φ(ζ) is analytic in a strip containing R; the singularities nearest to the originoccur at ±2

√π exp(±iπ/4). The first coefficients of the Taylor expansion

φ(ζ) = d0 + d1ζ + d2ζ2 + d3ζ

3 + · · · (10.64)

are

d0 = 1, d1 = − 12 β√

2, d2 = 18 (2β

2 − 2β + 1), d3 = − 124β√

2(β2 − 3β + 2), (10.65)

d4 = 1384 (4β

4 − 24β3 + 32β2 − 12β + 1),

d5 = − 1960β

√2(β4 − 10β3 + 25β2 − 20β + 4).

(10.66)

From results in [211] it follows that the standard form (10.58) can be written in the form

Ix(a, a+ β) = 12 erfc(−η√a/2)− Ra(η), (10.67)

where η is defined in (10.54). We try to solve (10.51) with the above representation of theincomplete beta function. First we solve (10.51) in terms of η; afterwards, we determine xfrom the inverse relation of the second line in (10.54) (that is, (10.56) with t, ζ replaced byx, η, respectively). When a is large, we consider the error function in the equation

Ix(a, a+ β) = 12 erfc(−η√a/2)− Ra(η) = p (10.68)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 13: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

10.5. Asymptotic inversion of the incomplete beta function 321

as the dominant term, and a first approximation η0 of η is defined by the solution of theequation

12 erfc(−η0

√a/2) = p. (10.69)

The exact solution of (10.51) (in terms of η) is written as

η = η0 + ε, (10.70)

and we try to determine ε. It appears that we can expand this quantity in the form

ε ∼ ε1

a+ ε2

a2+ ε3

a3+ · · · , (10.71)

as a→∞. The coefficients εi can be expressed in terms of η0 and β.From (10.58), (10.68), and (10.69) we obtain

dp

dη0=√a

2πe−

12 aη

20 ,

dp

dη=√a

2πf(η)e−

12 aη

2, (10.72)

where f is given in (10.59). Upon dividing, we obtain

f(η)dη

dη0= e 1

2 a(η2−η2

0). (10.73)

Substitution of (10.70) gives the differential equation

f(η0 + ε)(

1+ dε

dη0

)= eaε(η0+ 1

2 ε). (10.74)

We write η in place of η0; that is, we try to find ε as a function of η that satisfies (see also(10.59))

φ(η+ ε)�(a)(

1+ dεdη

)= eaε(η+ 1

2 ε). (10.75)

When we have obtained ε from this equation (or an approximation), we use it in (10.70) toobtain the final value η.

The first coefficient ε1 of (10.71) is obtained by comparing dominant terms in (10.75).Since �(a) = 1+O(a−1), we obtain

ε1 = 1

ηln φ(η). (10.76)

This quantity is analytic (as a function of η) on R; φ(η) is positive on R, and φ(0) = 1.Using (10.64) we obtain for small values of η

ε1 = − 12β√

2+ 18 (1− 2β)η− 1

48β√

2η2 − 1192η

3 − 13840β

√2η4 + · · · . (10.77)

Further terms εi can be obtained by using more terms in (10.62) and by expanding

φ(η+ ε) = φ(η)+ εφ′(η)+ 12ε

2φ′′(η)+ · · · , (10.78)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 14: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

322 Chapter 10. Inversion of Cumulative Distribution Functions

in which (10.71) is substituted to obtain an expansion in powers of a−1. In this way we find

ε2 = 1

2ηφ(2φε′1 + 2φ′ε1 + 2c1φ − φε2

1), (10.79)

ε3 = 1

8ηφ(8φε′2 + 8φ′ε1ε

′1 + 8c1φε

′1 + 8φ′ε2 + 4φ′′ε2

1 (10.80)+ 8c1φ

′ε1 + 8c2φ − 8φε1ε2 − 4φε22η

2 − 4φε2ηε21 − φε4

1).

The derivatives φ′, ε′, etc., are with respect to η, and all functions are evaluated at η. Forsmall values of η we can use the Maclaurin series

ε2 = β√

2

12(3β − 2)+ 1

128(20β2 − 12β + 1)η+ β

√2

960(20β − 1)η2 + · · · ,

ε3 = β√

2

480(−75β2 + 80β − 16)+ · · · .

(10.81)

10.5.2 The general error function case

Let us writea = r sin2 θ, b = r cos2 θ, 0 ≤ θ ≤ 1

2π. (10.82)

Then (10.49) can be written as

Ix(a, b) = 1

B(a, b)

∫ x

0er[sin2 θ ln t+cos2 θ ln(1−t)] dt

t(1− t) . (10.83)

We consider r as a large parameter, and θ bounded away from 0 and 12π. The maximum of

the exponential function occurs at t = sin2 θ. Hence, the following transformation bringsthe exponential part of the integrand into a Gaussian form:

−1

2ζ2 = sin2 θ ln

t

sin2 θ+ cos2 θ ln

1− tcos2 θ

, (10.84)

where the sign of ζ equals the sign of t − sin2 θ. The same transformation holds for x "→ η

if t and ζ are replaced with x and η, respectively. From (10.84) we obtain

−ζ dζdt= sin2 θ − tt(1− t) , (10.85)

and we can write (10.83) in the standard form (cf. (10.58)–(10.60))

Ix(a, b) =√r

∫ η

−∞e−

12 rζ

2f(ζ) dζ, (10.86)

withf(ζ) = �(r)φ(ζ), (10.87)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 15: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

10.5. Asymptotic inversion of the incomplete beta function 323

where

�(r) = �∗(r)�∗(a)�∗(b)

, φ(ζ) = ζ sin θ cos θ

t − sin2 θ. (10.88)

The function �∗(z) is the slowly varying part of the Euler gamma function, introduced in(8.28).

The analogue of the expansion (10.62) is now in terms of the large parameter r:

�(r) ∼ c0 + c1r−1 + c2r

−2 + · · · , r→∞, (10.89)

where

c0 = 1, c1 = sin2 θ cos2 θ − 1

3 sin2 2θ, c2 = (sin2 θ cos2 θ − 1)2

18 sin4 2θ, (10.90)

c3 = −139(sin6 θ cos6 θ − cos6 θ − sin6 θ)+ 15 sin4 θ cos4 θ

810 sin6 2θ. (10.91)

The first coefficients of the Taylor expansion

φ(ζ) = d0 + d1ζ + d2ζ2 + d3ζ

3 + · · · (10.92)

are

d0 = 1, d1 = −2

3cot 2θ, d2 = sin4 θ + cos4 θ + 1

6 sin2 2θ. (10.93)

To solve (10.51) for large values of r, we use the method of the previous section. Wewrite as in (10.67)

Ix(a, b) = 12 erfc(−η√r/2)− Ra(η), (10.94)

where the relation between x and η follows from (10.84) when t and ζ are replaced with xand η, respectively. A first approximation η0 follows from the equation

12 erfc(−η0

√r/2) = p, (10.95)

and the terms εi in the expansion

ε ∼ ε1

r+ ε2

r2+ ε3

r3+ · · · (10.96)

are the same as in (10.76), (10.77), and (10.80), but with φ, c1, c2 of the present section.For small values of η we can expand

ε1 = 2s2 − 1

3sc− 5s4 − 5s2 − 1

36s2c2η+ 46s6 − 69s4 + 21s2 + 1

1620s3c3η2 + · · · ,

ε2 = −52s6 − 78s4 + 12s2 + 7

405s3c3+ 2s2 − 370s6 + 185s8 + 183s4 − 7

2592s4c4η+ · · · ,

ε3 = 3704s10 − 9260s8 + 6686s6 − 769s4 − 1259s2 + 449

102060s5c5+ · · · ,

(10.97)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 16: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

324 Chapter 10. Inversion of Cumulative Distribution Functions

where s = sin θ, c = cos θ.The functions εi are now considered as functions of η0 (instead of η), and we write

η ∼ η0 + ε1

r+ ε2

r2+ ε3

r3+ · · · . (10.98)

This approximation is substituted on the left-hand side of (10.84), and we invert this equationto obtain t or, equivalently, x.

10.5.3 The incomplete gamma function case

In this section we consider the asymptotic condition that the sum a + b should be large.We concentrate on the case a ≥ b. In the other case we can solve (10.51) by using (10.52).From [214, eq. (9.16)] it follows that we can write

Ix(a, b) = Q(b, ηa)+ Ra,b(η), (10.99)

where η is given by a mapping x "→ η, which is defined by

η− µ ln η+ A(µ) = − ln x− µ ln(1− x) (10.100)

and

µ = ba, A(µ) = (1+ µ) ln(1+ µ)− µ. (10.101)

Q is the incomplete gamma function defined by (8.12). Corresponding points in the mappingdefined in (10.100) are

x = 0 ↔ η = +∞, x = 1

1+ µ ↔ η = µ, x = 1 ↔ η = 0. (10.102)

From (10.100) it follows that

dx

dη= η− µ

η

x(1− x)(1+ µ)x− 1

. (10.103)

In [214] an asymptotic expansion of Ra,b(η) in (10.99) is derived, which holds for a→∞,uniformly with respect to x ∈ [0, 1] and b ∈ [0,∞).

We obtain the solution of (10.51) for large values of a by first determining η0, thesolution of the reduced equation

Q(b, η0a) = p. (10.104)

This involves an inversion of the incomplete gamma function, whose problem is consideredin §10.3, especially for large values of b. As in the previous sections, the exact solution of(10.51) is written as η = η0 + ε, and we expand ε as in (10.71). We have (cf. (10.72))

dp

dη0= − ab

η0�(b)ea(−η0+µ ln η0),

dp

dη= 1

B(a, b)x(1− x)dx

dηea[−η+µ ln η−A(µ)].

(10.105)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 17: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

10.5. Asymptotic inversion of the incomplete beta function 325

Upon dividing these equations and using (10.103), we obtain

f(η)dη

dη0= η

η0ea[η−η0−µ ln(η/η0)], (10.106)

with f(η) = φ(η)�(a), and

φ(η) = η− µ1− x(1+ µ)

1√1+ µ, �(a) = �

∗(a+ b)�∗(a)

, (10.107)

where �∗ is introduced in (8.28). By writing η = η0 + ε, and writing η in place of η0 (forthe time being), (10.106) can be written as

φ(η+ ε)�(a)(

1+ dεdη

)= ea[ε−µ ln(1+ε/η)]. (10.108)

The analogue of the expansion (10.62) has the coefficients

c0 = 1, c1 = − µ

12(1+ µ), c2 = µ2

288(1+ µ)2 , (10.109)

c3 = µ(432+ 432µ+ 139µ2)

51840(1+ µ)3 . (10.110)

The analogue of (10.64) reads

φ(η) = d0 + d1(η− µ)+ d2(η− µ)2 + · · · , (10.111)

with coefficients

d0 = 1, d1 = w+ 2

3(w+ 1)w, d2 = 1

12w2, d3 = 8w3 + 9w2 − 9w− 8

540w(w+ 1)3, (10.112)

wherew = √

1+ µ. (10.113)

Substituting

ε ∼ ε1

a+ ε2

a2+ ε3

a3+ · · · (10.114)

into (10.108), we find the first coefficient,

ε1 = ln φ(η)

1− µ/η, (10.115)

a regular function at η = µ, as follows from the expansion (10.111) of φ(η) at this point.The next term is

ε2 = 1

2φη(η− µ)(2φε′1η

2 + 2φ′ε1η2 + 2c1φη

2 − φµε21 − 2ε1φη), (10.116)

where the derivatives are with respect to η. For small values of |η− µ| we can expand

ε1 = (w+ 2)(w− 1)

3w+ w

3 + 9w2 + 21w+ 5

36w2(w+ 1)(η− µ)+ · · · , (10.117)

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 18: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

326 Chapter 10. Inversion of Cumulative Distribution Functions

ε2 = (28w4 + 131w3 + 402w2 + 581w+ 208)(w− 1)

1620(w+ 1)w3+ · · · , (10.118)

where w is given by (10.113).Considering the functions εi as functions of η0, we obtain using (10.114)

η ∼ η0 + ε1

a+ ε2

a2+ ε3

a3+ · · · , (10.119)

which is substituted on the left-hand side of (10.100). Solving for x, we finally obtain thedesired approximation of the solution of (10.51).

In this section, the functions�(a), φ(η), ε have expansions with coefficients ci, di, εiin which the parameterµ = b/amay assume any value in [0,∞). This aspect demonstratesthe uniform character (with respect toµ) of the present approach. In §10.5.1 large values ofβ are not allowed, and in §10.5.2 the value of θ should be bounded away from 0 and 1

2π. Ofcourse, the transformations and expansions of this section are more complicated than thosein the previous sections. Moreover, to start the inversion procedure, first (10.104) includingan incomplete gamma function should be solved, whereas in the foregoing cases only anerror function has to be inverted; see (10.69) and (10.95).

10.5.4 Numerical aspects

In numerical applications one needs the inversion of the mappings given in (10.54), (10.84),and (10.100). Only (10.54) can be inverted directly, as shown in (10.56). For small valuesof |ζ| we have

t = 12 + 1

4

√2ζ − 1

32

√2ζ3 + 5

1536

√2ζ5 + · · · . (10.120)

The inversion of (10.100) can be based on that of (10.84), with other parameters. We givesome details on the inversion of (10.84).

For small values of |ζ| we have

t = s2 + scζ + 1− 2s2

3ζ2 + 13s4 − 13s2 + 1

36scζ3 + · · · , (10.121)

where s = sin θ, c = cos θ. For larger values of |ζ|, with ζ < 0, we rewrite (10.84) in theform

t(1− t)α = u, α = cot2 θ, u = exp[(− 1

2ζ2 + s2 ln s2 + c2 ln c2

)/s2

], (10.122)

and for small values of u we expand

t = u+ αu2 + 3α(3α+ 1)

3! u3 + 4α(4α+ 1)(4α+ 2)

4! u4 + · · · . (10.123)

A similar approach is possible for positive values of ζ, giving an expansion for t near unity.The approximations obtained in this way may be used for starting a Newton–Raphsonmethod for obtaining more accurate values of t.

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 19: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

10.6. High order Newton-like methods 327

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 110

−7

10−6

10−5

10−4

10−3

10−2

10−1

|I x(a,a

+β)

−p|

/p

p

β=0β=1β=2β=3

Figure 10.1. Relative errors |Ix(a, a + β) − p|/p for a = 10 and several valuesof p and β. The asymptotic inversion is based on the method of §10.5.1.

We have tested the inversion process of the incomplete beta function for several valuesof the parameters. We describe the testing for the method of §10.5.1. After obtaining the firstapproximation η0 by inverting (10.69), we compute the values of ε1, ε2, ε3, (10.76)–(10.80)(with η replaced with η0). The coefficient ε3 is included only when η0 is small enough forusing the Maclaurin series given in §10.5.1. Next, (10.70) gives the final approximation ofη, which is used in the second line in (10.54), to obtain the approximation of x. Finally weverified (10.51) by computing the incomplete beta function with this value x. We used thecontinued fraction given in (6.78).

In Figures 10.1, 10.2, and 10.3, we show the relative errors |(Ix(a, b)−p)/p|, wherex is obtained by the asymptotic inversion methods of the previous sections. As is expected,it follows that the larger values of β give less accuracy in the results in Figure 10.1. Thesame holds for smaller values of θ in Figure 10.2. From Figure 10.3 it follows that theresults are not influenced by large or small values of µ. This shows the uniform characterof the method of §10.5.3. In fact, this method can be used in extreme situations: the ratioa/b may be very small and very large, and p may assume values quite close to zero or tounity.

10.6 High order Newton-like methodsSpecial functions usually satisfy a simple ordinary differential equation, and this equationcan be used to construct Newton-like methods of high order.

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 20: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

328 Chapter 10. Inversion of Cumulative Distribution Functions

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 110

−7

10−6

10−5

10−4

10−3

10−2

p

|I x(a,b

)−p|

/p

sin2θ=0.5sin2θ=0.4sin2θ=0.3sin2θ=0.2

Figure 10.2. Relative errors |Ix(a, b) − p|/p for r = a + b = 10 and severalvalues of p and sin2 θ = a/r. The asymptotic inversion is based on the method of §10.5.2.

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 110

−8

10−7

10−6

10−5

10−4

10−3

p

|I x(a,b

)−p|

/p

µ=0.1µ=0.5µ=2µ=10

Figure 10.3. Relative errors |Ix(a, b)− p|/p for a = 10 and several values of pand µ = b/a. The asymptotic inversion is based on the method of §10.5.3.

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 21: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

10.6. High order Newton-like methods 329

Let f(z) be the function, the zero ζ of which has to be computed. We put ζ =ζ0 + h, where ζ0 is an approximation of this zero, and we assume that we can expand in aneighborhood of this point

f(ζ) = f(ζ0 + h) = f(ζ0)+ hf1 + 1

2!h2f2 + 1

3!f3 + · · · , (10.124)

where fk denotes the kth derivative of f at ζ0. We assume that f(ζ0) is small and we expand

h = c1f(ζ0)+ c2f2(ζ0)+ c3f

3(ζ0)+ · · · . (10.125)

Substituting this expansion into (10.124), using that f(ζ) = 0, and comparing equal powersof f(ζ0), we find, when f1 �= 0,

c1 = − 1

f1, c2 = − f2

2f 31

,

c3 = −3f 22 + f 3

3 f1

6f 51

, c4 = −f4f21 + 15f 3

2 − 10f2f3f1

24f 71

.

(10.126)

When we neglect in (10.125) the coefficients ck with k ≥ 2, we obtain Newton–Raphson,with ζ=̇ζ0 − f(ζ0)/f

′(ζ0).When f(z) satisfies a simple ordinary differential equation, the higher derivatives can

be replaced by combinations of lower derivatives.

Example 10.1 (the inversion of the incomplete gamma function). In §10.3 we have con-sidered the inversion of the equations

P(a, x) = p, Q(a, x) = q, (10.127)

where 0 < p < 1, 0 < q < 1, for large positive values of a. When a is small theasymptotic methods cannot be applied, although for a = 1 the results can be used as a firstapproximation. Now we take a ∈ (0, 1], f(x) = P(a, x) − p, and an initial value x0 > 0.We derive from (8.12) the values

c1 = −x1−a0 ex0�(a),

c2 = x0 + 1− a2x0

c21,

c3 = 2x20 + 4x0(1− a)+ 2a2 − 3a+ 1

6x20

c31,

c4 = 6x30 + 18x2

0(1− a)+ x0(18a2 − 29a+ 11)− 6a3 + 11a2 − 6a+ 1

24x30

c41.

(10.128)

For a = 1 the equation f(x) = 0 is simple, because P(1, x) = 1 − e−x and the solutionof f(x) = 0 is x = − ln(1 − p). The values ck are in this case ck = (−1)kekx0/k,k = 1, 2, 3, . . . , and h of (10.125) becomes h =∑∞

k=1 ckfk = − ln(1+ ex0f(x0)). Using

this value of h we obtain

x = x0 + h = x0 − ln(1+ ex0f(x0)) = − ln(1− p), (10.129)

which gives the exact solution of f(x) = 0 for any x0 > 0.

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php

Page 22: Numerical Methods for Special Functions || 10. Inversion of Cumulative Distribution Functions

330 Chapter 10. Inversion of Cumulative Distribution Functions

For general a ∈ (0, 1] we derive a convenient starting value x0. We observe that

P(a, x) = 1

�(a)

∫ x

0ta−1e−t dt <

1

�(a)

∫ x

0ta−1 dt = xa

�(a+ 1). (10.130)

Hence, the solution x0 of the equation xa = p�(a+ 1) satisfies 0 < x0 < x, where x is theexact solution of f(x) = 0.

The case a = 12 is of special interest, because P( 1

2 , x) = erf√x, the error func-

tion. For a numerical example for that case we take p = 0.5. We have x0 = π/16 =0.196349540849362 and f(x0) = erf

√x0 − 1

2 = −0.030884051069941. Using the val-ues c1, c2, c3, c4 from (10.128), we have h = 0.0311185517296367. This gives the newapproximation x =̇ x0 + h = 0.227468092579000 and with this value we have f(x) =−1.12 . . . 10−7. It is easy to iterate and to obtain much higher accuracy. �

Dow

nloa

ded

07/0

5/14

to 1

28.6

.218

.72.

Red

istr

ibut

ion

subj

ect t

o SI

AM

lice

nse

or c

opyr

ight

; see

http

://w

ww

.sia

m.o

rg/jo

urna

ls/o

jsa.

php