A Bayesian nonparametric chi-squared goodness-of-fit

arXiv:1602.00197v3 [] 16 Jun 2016

test

June 20, 2016

Reyhaneh Hosseini and Mahmoud Zarepour
Department of Mathematics and Statistics
University of Ottawa

Abstract
The Bayesian nonparametric inference and Dirichlet process are popular tools in
Bayesian statistical methodologies. In this paper, we employ the Dirichlet process in
a hypothesis testing to propose a Bayesian nonparametric chi-squared goodness-of-fit
test. In our new Bayesian nonparametric approach, we consider the Dirichlet process as
the prior for the distribution of the data and carry out the test based on the KullbackLeibler distance between the updated Dirichlet process and the hypothesized distribution. We prove that this distance asymptotically converges to the same chi-squared

1

distribution as the classical frequentist’s chi-squared test does. Moreover, a Bayesian
nonparametric chi-squared test of independence for a contingency table is described.
In addition, by computing the Kullback-Leibler distance between the Dirichlet process
and the hypothesized distribution, a method to obtain an appropriate concentration
parameter for the Dirichlet process is presented.

Keywords: Bayesian nonparametric inference, Dirichlet process, Pearson’s chi-squared test,
chi-squared test of independence, goodness-of-fit test, Brownian bridge, Kullback-Leibler
distance.
MSC 2010: Primary 62G20; secondary 62G10.

1

Introduction

The Bayesian nonparametric plays a crucial role in statistical inference. The Dirichlet process perhaps is the most popular prior in Bayesian nonparametric statistics and it has been
applied in many different areas of statistical inference. The most common applications of
Dirichlet process are in density estimation and clustering via mixture models. See for instance, Neal [31], Lo [27] and Escobar and West [12]. In this paper, we suggest a Bayesian
nonparametric chi-squared goodness-of-fit test based on the Kullback-Leibler distance between the posterior Dirichlet process and the hypothesized distribution.
There are many one-sample and two-sample parametric goodness-of-fit tests in the literature. See for example, D’Agostino [10] for a review. The chi-squared test examines whether
the data has a specified distribution F0 , i.e., the null hypothesis is given as H0 : F = F0
where F0 is the true distribution for the observed data. Some extensions of chi-squared
goodness-of-fit test to Bayesian model assessment where the test statistic is based on the
2

posterior distribution, are described by Johnson [23] and Johnson [24].
In Bayesian nonparametric inference, there are two strategies of goodness-of-fit test.
The first strategy considers a prior for the true distribution of data and constructs the
test based on the distance between the posterior distribution and the proposed one. For
example, Muliere and Tardella [30], Swartz [33], Al Labadi and Zarepour [3, 4] considered
the Dirichlet process prior and the Kolmogorov distance. Al Labadi and Zarepour [4] and
Al Labadi et al. [2] carried out a goodness-of-fit test and a two-sample goodness-of-fit test,
respectively by considering the Dirichlet process as a prior and the test statistic based on the
Kolmogorov distance. Viele [36] used the Dirichlet process and the Kullback-Leibler distance
for testing the discrete distributions. Hsieh [20] considered the Polya tree model as the prior
and measured the Kullback-Leibler distance for testing the continuous distributions.
The second strategy is conducted by embedding the hypothesized model H0 in an alternative model H1 and placing a prior on that. To examine the hypothesized model, the Bayes
factor is used as a measure of evidence against the hypothesized model. For example, Carota
and Parmigiani [9] and Florens et al. [15] used a Dirichlet process prior for the alternative
model. Tokdar and Martin [34] carried out a Bayesian test for normality by considering
a Dirichlet process mixture for the alternative model. Some authors used other Bayesian
nonparametric priors. For instance, Holmes et al. [19] described a Bayesian nonparametric
two sample hypothesis testing based on a Polya tree prior. In order to test for the normal
distribution, Berger and Guglielmi [5] considered a mixture of Polya trees for the alternative
model distribution, while Verdinelli and Wasserman [35] suggested a mixture of Gaussian
processes.
Our new proposed chi-squared goodness of fit test is based on the first approach discussed above. We consider a Dirichlet process prior for the distribution of the observed data
3

and define the chi-squared test statistic based on the Kullback-Leibler distance between the
Dirichlet process posterior and the hypothesized distribution. In fact, in our Bayesian nonparametric approach, the test proceeds by constructing the chi-squared test statistic based on
the distance between the observed probabilities obtained by the Dirichlet process posterior
and the expected probabilities. Indeed, instead of counting the observed frequencies in each
bin, we place a prior on the distribution of the data. The probability of each bin is obtained
by the exact posterior probability of that bin. Then, our new test statistic compares the
posterior probabilities with the probabilities under the null hypothesis. In this procedure,
based on the suggested Dirichlet prior, we know the exact distribution of the test statistic.
Using a similar approach, we also determine an appropriate concentration parameter for the
Dirichlet process which is required to decide on an appropriate prior.
The outline of the paper is organized as follows. In Section 2, we give an essential background on Dirichlet process and its properties. In Section 3, we briefly review the definition
of the Kullback-Leibler divergence. Following this, we obtain the Kullback-Leibler distance
between the Dirichlet process and a continuous distribution and compute its mean and variance. Section 4 discusses a Bayesian nonparametric chi-squared goodness-of-fit test based on
the Kullback-Leibler distance between the Dirichlet process posterior and the hypothesized
distribution. In Section 5, we extend our suggested chi-squared test to present a Bayesian
nonparametric chi-squared test of independence of two random variables. We also describe
a method to obtain an appropriate concentration parameter based on the Kullback-Leibler
distance between the Dirichlet process and the proposed distribution. Simulation studies of
the tests with a data illustration appear in Section 6. In the final section, we conclude with
a brief discussion and the Appendix contains the theoretical results.

4

2

Dirichlet Process

In this section, we review the construction, various properties and some series representations
of the Dirichlet process. The Dirichlet process was initially formalized by Ferguson [13] for
general Bayesian statistical modeling as a distribution over probability distributions.
Definition 2.1. (Ferguson [13]) Let X be a set, A be a σ−field of subsets of X , H be
a probability measure on (X , A ) and α > 0. A random probability measure P with parameters α and H is called a Dirichlet process (denoted by P ∼ DP (αH) ) on (X , A )
if for any finite measurable partition {A1 , . . . , Ak } of X , the joint distribution of the random variables P (A1 ), . . . , P (Ak ) is a k-dimensional Dirichlet distribution with parameters
αH(A1 ), . . . , αH(Ak ), where k ≥ 2.
We assume that if H(Ak ) = 0, then P (Ak ) = 0 with probability one. Then, a Dirichlet
process is parameterized by α and H which are called the concentration parameter and
the base distribution, respectively. The base distribution is also the mean of the Dirichlet
process, i.e., for any measurable set A ⊂ X , E (P (A)) = H(A). One of the most remarkable
properties of the Dirichlet process is that it satisfies the conjugacy property. Let X1 , . . . , Xm
be an i.i.d. sample from P ∼ DP (αH). The posterior distribution of P given X1 , . . . , Xm is
a Dirichlet process with parameters
∗
αm

= α + m and

∗
Hm

m
α
H+
=
α+m
α+m

Pm

i=1 δXi

m

(2.1)

∗
∗
and denoted by Pm∗ = (P | X1 , . . . , Xm ) ∼ DP (αm
Hm
), where δX (·) is the Dirac measure,

i.e., δX (A) = 1 if X ∈ A and 0 otherwise.
∗
As it is seen in (2.1), the posterior base distribution Hm
is a weighted average of H and

5

the empirical distribution Fm =

Pm

i=1 δXi

m

a.s.

∗
. Thus, for large values of α, Hm
→ H. On the

∗
other hand, as α → 0 or as the number of observations m grows large, Hm
becomes non∗
is just given by the empirical distribution and is a close
informative in the sense that Hm

approximation of the true underlying distribution of Xi , i = 1, . . . , m. This confirms the
consistency property of the Dirichlet process, i.e., the posterior Dirichlet process approaches
the true underlying distribution. For a discussion about the consistency property of Dirichlet
process, see Ghosal [16] and James [22].
A sum representation of Dirichlet process is presented by Ferguson [13] based on the work
of Ferguson and Klass [14]. Specifically, let (θi )i≥1 be a sequence of i.i.d. random variables
with common distribution H and (Ek )k≥1 be a sequence of i.i.d. random variables from the
exponential distribution with mean 1. If Γi = E1 + · · · + Ei and (Γi )i≥1 are independent from
(θi )i≥1 , then,

P =

∞
∞
X
X
L−1 (Γi )
δ
=
pi δθi
θi
∞
P
−1
i=1
i=1
L (Γi )

(2.2)

i=1

is a Dirichlet process with parameters α and H where L(x) = α

R∞
x

t−1 e−t dt, x > 0 and

L−1 (y) = inf{x > 0 : L(x) ≥ y}. Ishwaran and Zarepour [21] introduced a finite sum
approximation for the Dirichlet process which is easier to work with. Let p = (p1,n , . . . , pn,n )
has a Dirichlet distribution with parameters (α/n, . . . , α/n) denoted by Dir(α/n, . . . , α/n)
and (θi )1≤i≤n be a sequence of i.i.d. random variables with distribution H and independent of
(pi,n )1≤i≤n . Also, let (Gi,n )1≤i≤n be i.i.d. random variables from Gamma(α/n, 1) distribution
and pi,n = Gi,n /Gn , where Gn = G1,n + · · · + Gn,n . Then,

Pn =

n
X

pi,n δθi =

i=1

n
X
Gi,n
i=1

6

Gn

δθ i

(2.3)

is called a finite-dimensional Dirichlet process and approximates the Ferguson’s Dirichlet
process weakly. Another finite sum representation of the Dirichlet process with monotonically
decreasing weights is presented in Zarepour and Al Labadi [39]. Specifically, let (θi )1≤i≤n
be a sequence of i.i.d. random variables with values in X and common distribution H and
independent of (Γi )1≤i≤n+1 . Let Xn ∼ Gamma(α/n, 1) and define
1
Gn (x) = Pr(Xn > x) =
Γ(α/n)

Z

∞

t(α/n)−1 e−t dt

x

and

G−1
n (y) = inf{x : Gn (x) ≥ y}.
Then, as n → ∞,
Γi
∞
n
X
X
G−1
L−1 (Γi )
n ( Γn+1 )
a.s.
δθi → P =
Pn =
δθ i .
n
∞
P
P
Γi
−1 (Γ )
i=1
i=1
)
G−1
(
L
i
n Γn+1
i=1

(2.4)

i=1

If we define
pi,n

Γi
G−1
n ( Γn+1 )
,
= P
n
Γi
−1
Gn ( Γn+1 )

(2.5)

i=1

then, Pn can be written as

n
X
Pn =
pi,n δθi .

(2.6)

i=1

This finite sum representation converges almost surely to Ferguson’s representation and
empirically converges faster than the other representations. For other sum representations of
Dirichlet process, see for example, ? ] and Bondesson [8]. In the next section, we will discuss
computing the Kullback-Leibler distance between the Dirichlet process and a continuous
7

distribution and its mean and variance.

3

Kullback-Leibler distance between the Dirichlet process and a continuous distribution

The Kullback-Leibler distance that measures the distance between two distributions introduced by Kullback and Leibler [26]. Suppose P and Q are two probability measures for
discrete random variables on a measurable space (Ω, F). The Kullback-Leibler divergence
between P and Q is defined as


X
P(i)
.
DKL (P k Q) =
P(i) log
Q(i)
i

(3.1)

For continuous probability measures P and Q with P absolutely continuous with respect to
Q, the Kullback-Leibler distance is written as


Z
DKL (P k Q) =
where

dP
dQ

log

dP
dQ


dP

is the Radon-Nikodym derivative of P with respect to Q. Let P  λ and Q  λ

where λ is the Lebesgue measure. If the densities of P and Q with respect to Lebesgue
measure are denoted by p(x) and q(x), respectively, then the Kullback-Leibler distance is
written as


Z
DKL (P k Q) =

p(x) log

p(x)
q(x)


dx.

(3.2)

R

We compute the distance between the random distribution P from a Dirichlet process
DP (αH) and a continuous distribution F with density f (x). Since P is a discrete mea8

sure and F is continuous, we estimate the density f (x) by its histogram estimator on a
partitioned space. Also, since the Kullback-Leibler distance is not symmetric, we compute
both distances DKL (P k F ) and DKL (F k P ).
Lemma 3.1. Let H and F be two distributions defined on the same space X and Pn =
Pn
i=1 pi,n δθi be a random distribution as defined in (2.3), i.e., θ1 , . . . , θn are i.i.d. generated
from H with corresponding order statistics θ(1) , . . . , θ(n) . We have
n
X

pi,n log(qi )

(3.3)

n
X
DKL (F k Pn ) = −H(q) −
qi log(pi,n )

(3.4)

DKL (Pn k F ) = −H(p) −

i=1

and

i=1

where H(p) = −

n
P

pi,n log(pi,n ) is the entropy of Pn and H(q) = −

n
P

qi log(qi ) with qi =

i=1

i=1
4F (xi )
.
4xi

Proof. See the Appendix.
The mean and the variance of the Kullback-Leibler divergences (3.3) and (3.4) are given
in the following Proposition and Remark.
Proposition 3.1. Let H and F be distributions defined on the same space X and Pn =
Pn
i=1 pi,n δθi be a random distribution as defined in (2.3), i.e., θ1 , . . . , θn are i.i.d. generated
from H with corresponding order statistics θ(1) , . . . , θ(n) . Then, the mean and the variance
of the Kullback-Leibler divergence (3.3) are given as
n
 α

 1X
E(DKL (Pn k F )) = n ψ
+ 1 − ψ(α + 1) −
log(qi )
n
n i=1

9

(3.5)

and

V ar(DKL (Pn k F )) =

n
X


V ar (pi,n log(pi,n )) + (log(qi ))2 V ar(pi,n )

i=1
n
X
−2
{log(qi )Cov (pi,n log(pi,n ), pi,n )}
i=1

X
+2
{Cov (pi,n log(pi,n ), pj,n log(pj,n )) + log(qi ) log(qj )Cov (pi,n , pj,n )}
i<j

X
−4
{log(qi )Cov (pi,n log(pi,n ), pj,n )} ,

(3.6)

i<j

respectively, where
V ar(pi,n )

=

Cov (pi,n , pj,n )

=

V ar (pi,n log(pi,n ))

=

Cov (pi,n log(pi,n ), pi,n )

=

Cov (pi,n log(pi,n ), pj,n )

=

Cov (pi,n log(pi,n ), pj,n log(pj,n ))

=

and ψ(α) =

d ln(Γ(α))
dα

n−1
,
n2 (α + 1)
−1
,
n2 (α + 1)
 

h α

i2 
(α/n) + 1
α
ψ1
+ 2 − ψ1 (α + 2) + ψ
+ 2 − ψ(α + 2)
n(α + 1)
n
n
 α
2
− ψ( + 1) − ψ(α + 1) ,
n

 1  α


(α/n) + 1   α
+ 2 − ψ(α + 2) −
+ 1 − ψ(α + 1) ,
ψ
ψ
n(α + 1)
n
n
n
 α

 1  α


α
ψ
+
1
−
ψ(α
+
2)
−
ψ
+
1
−
ψ(α
+
1)
,
n2 (α + 1)
n
n
n
 


2 αψ (α + 2)
α
α
1
− 2
ψ
+
1
−
ψ(α
+
2)
n2 (α + 1)
n
n (α + 1)
 α

2
− ψ
+ 1 − ψ(α + 1)
n

and ψ1 (α) =

d2 ln(Γ(α))
dα2

=

dψ(α)
dα

are called digamma and trigamma

functions, respectively.
Proof. The proof is given in Appendix.
Remark 3.1. Let H and F be two distributions defined on the same space X and Pn =
10

Pn

i=1

pi,n δθi be the finite dimensional distribution as defined in (2.3), in which θ1 , . . . , θn are

i.i.d. generated from H with corresponding order statistics θ(1) , . . . , θ(n) . The mean and the
variance of the Kullback-Leibler divergence (3.4) can be obtained as
 α

E(DKL (F k Pn )) = −H(q) − ψ
− ψ(α)
n

(3.7)

and

V ar(DKL (F k Pn )) =

n
X
i=1

qi2 ψ1

α
n

− ψ1 (α),

(3.8)

respectively.
Proof. The proof is given in Appendix.

4

Bayesian nonparametric chi-squared goodness-of-fit test

The null hypothesis of the goodness-of-fit test is given as H0 : F = F0 where F is the
true underlying distribution of the observed data and F0 is some specified distribution.
Pearson’s chi-squared goodness of fit test proceeds by partitioning the sample space into k
non-overlapping bins and comparing the observed counts with the expected counts under the
null hypothesis for each bin. Suppose X1 , . . . , Xm is a sample of size m from the distribution
F . Let Oi and Ei , i = 1, . . . , k denote the observed counts and the expected counts under
the hypothesized distribution F0 for bin k, respectively. The Pearson’s goodness-of-fit test
statistic is defined as

11

X2 =

k
X
(Oi − Ei )2
i=1

Ei

(4.1)

and X 2 asymptotically converges to a chi-squared distribution with k − 1 degrees of freedom.
To derive a counter part Bayesian nonparametric test statistic similar to X 2 , we consider
a Dirichlet process with parameters α and H = F0 as a prior for the true distribution of
data, i.e., X1 , . . . , Xm ∼ P where P ∼ DP (αH). Then, given X1 , . . . , Xm , the posterior
∗
∗
∗
distribution of P is a Dirichlet process Pm∗ = (P | X1 , . . . , Xm ) ∼ DP (αm
Hm
) where αm
∗
are as given in (2.1). We carry out the test based on the chi-squared distance
and Hm

between the posterior Dirichlet process Pm∗ and the hypothesized distribution F0 . Note
that for the large sample size, both the Pearson’s goodness-of-fit test and the likelihood
ratio test (the Kullback-Leibler distance) are asymptotically equivalent. For simplicity, we
only consider Pearson’s goodness-of-fit test. Theorem 4.1 describes this connection and the
asymptotic distribution for the law of the posterior distance for large sample size which
is equivalent to the frequentist’s chi-squared test. This result follows from Al Labadi [1]
and Lo [28], but we include a simple calculation to show the asymptotic distribution of
√
∗
(A)) where A ∈ X . Notice that by having the partition {A, Ac }
Dαm (A) = m(Pm∗ (A) − Hm
and the definition of Dirichlet process,
∗
∗
∗
∗
Pm∗ (A) ∼ Beta (αm
Hm
(A), αm
Hm
(Ac )) .

∗
∗
Set Y = Pm∗ (A) and v = Hm
(A) where Pm∗ and Hm
are defined in (2.1). Then, for 0 < y < 1,

the random variable Y has the probability density function

f (y) =

Γ(m)
∗
∗
y αm v−1 (1 − y)αm (1−v)−1 .
Γ(mv)Γ(m(1 − v))
12

Thus, the probability density function of Z =

Γ(m)
fZ (z) =
Γ(mv)Γ(m(1 − v))



√

m(Y − v) in its support is

z
√ +v
m

α∗m v−1 

z
1− √ −v
m

α∗m (1−v)−1
.

(4.2)

By Scheffé’s theorem (Billingsley [7], page 29), we need to show that


z2
fZ (z) → √
exp − 2 ,
2σ
2πσ 2
1

where σ 2 = F (A)(1 − F (A)). By Stirling’s formula, we have

Γ (x) ≈

√

1

2πxx− 2 e−x as x → ∞,

where we use the notation f (x) ≈ g(x) as x → ∞ if lim

f (x)
x→∞ g(x)

= 1. From (2.1), as m → ∞,

a.s.

∗
∗
= α + m ≈ m. Then, the equation (4.2) can be rewritten as
→ F and αm
Hm

Γ (m)
fZ (z) =
Γ (mv) Γ (m (1 − v))



z
√ +v
m

where v = F (A). Then,

13

mv−1 

z
1− √ −v
m

m(1−v)−1
,


mv−1 

 √zm + v
1−

1
lim fZ (z) = √
lim
m→∞
2π m→∞ 


√z
m

m(1−v)−1 


−v

1
1

v mv− 2 (1 − v)m(1−v)− 2


mv−1 
m(1−v)−1 


z
√
 √zm + v

1− m −v

1
lim
= p

v mv−1 (1 − v)m(1−v)−1
2πv(1 − v) m→∞ 


(
mv−1 
m(1−v)−1 )
z
z
1
lim
1+ √
1− √
= p
mv
m(1 − v)
2πv(1 − v) m→∞
n
o
1
= p
exp lim m ln (ηm ) ,
(4.3)
m→∞
2πv(1 − v)
where

ηm =

z
1+ √
mv

v 

z
1− √
m(1 − v)

1−v
.

Therefore,

1
lim m ln (ηm ) = lim
m→∞
m→∞ 1/m






z
z
v ln 1 + √
+ (1 − v) ln 1 − √
.
mv
m(1 − v)

By applying the L’Hospital’s rule, we obtain

14

lim m ln (ηm ) =

m→∞

=
=
=



(1−v)z
 − vz

3/2
2(1−v)m3/2
2
2vm
+

lim (−m ) 
m→∞
 1 + √z

√ z
1
−
mv
m(1−v)


m
vz
(1 − v)z
√
lim
−√
m→∞ 2
mv + z
m(1 − v) − z


m
−z 2
√
√
lim
m→∞ 2
( mv + z)( m(1 − v) − z)
−z 2
.
2v(1 − v)

Substituting (4.4) in (4.3) completes the proof of normality of Dαm (A) =

√

(4.4)
m(Pm∗ (A) −

∗
Hm
(A)). A similar method proves that as m → ∞, for any partition {A1 , . . . , Ak } of the

space X ,

d

(Dαm (A1 ), Dαm (A2 ), . . . , Dαm (Ak )) → (BF (A1 ), BF (A2 ), . . . , BF (Ak )),
where BF is the Brownian bridge.
Remark 4.1. A Gaussian process {BF (A), A ∈ X } is called a Brownian bridge if E(BF (A)) =
0 and Cov(BF (Ai ), BF (Aj )) = F (Ai ∩ Aj ) − F (Ai ) ∩ F (Aj ), where Ai , Aj ∈ X . Now we can
imply the following Lemma.
Lemma 4.1. Let X1 , . . . , Xm be a random sample from the distribution H. If Pm∗ is the
Dirichlet process posterior given X1 , . . . , Xm . Then, as m → ∞,

Dαm (·) =

√
d
∗
m(Pm∗ (·) − Hm
(·)) → BF (·).

For a detailed proof similar to what we presented here, see Al Labadi [1]. Also, see James
15

[22], Ghosal [16] and Lo [28]. Al Labadi [1] proved that as α → ∞, Dα (·) =

√

α(P (·) −

d

H(·)) → BH (·). Theorem 4.1 describes the asymptotic distribution of the posterior distance
for a large sample size.
Theorem 4.1. Suppose X1 , . . . , Xm is a random sample from a distribution F on sample
∗
∗
∗
space X . Let P ∼ DP (αH) and Pm∗ = (P | X1 , . . . , Xm ) ∼ DP (αm
Hm
), where αm
=α+m
∗
=
and Hm

α
H
α+m

+

m
α+m

Pm

i=1 δXi

m

∗
. Let DKL (Pm∗ k Hm
) denotes the Kullback-Leibler distance

∗
. For any finite partition {A1 , . . . , Ak } of X , define
between Pm∗ and Hm

∗
∗
D(Pm∗ , Hm
) := αm

k
X
(P ∗ (Ai ) − H ∗ (Ai ))2
m

m

∗ (A )
Hm
i

i=1

.

(4.5)

Then, as m → ∞, we have

d

∗
∗
∗
2αm
DKL (Pm∗ k Hm
) ' D(Pm∗ , Hm
) → χ2(k−1) .

Proof. See the Appendix.
a.s.

∗
→ F and therefore the posterior Dirichlet
Note that as the sample size m increases, Hm

process Pm∗ converges to the true underlying distribution F of the observed data X1 , . . . , Xm .
In our methodology, we compute the observed probability for bin Ai , i = 1, . . . , k of the
partition {A1 , . . . , Ak } by calculating the posterior probability Pm∗ (Ai ), i = 1, . . . , k. Notice
that in our Bayesian paradigm, we need to embed our prior information in our test statistic.
In other words, the base distribution and the concentration parameter plays the role of the
prior knowledge. Moreover, we do not count the observed frequencies in each bin. Instead,
we calculate the exact posterior probability for each bin. Then, the X 2 distance in (4.5)
compares the posterior probabilities with the hypothesized ones. Additionally, there is no
16

need to apply the asymptotic distribution as we know the exact distribution of the X 2
distance via a Monte Carlo simulation. Also, There are many discussions for choosing the
number of bins in the literature and different criterion are suggested by various authors.
See, for example, Koehler and Gan [25], Mann and Wald [29], Williams Jr [38], Watson
[37], Hamdan [18], Dahiya and Gurland [11], ? ], Best and Rayner [6], Quine and Robinson
[32] and Johnson [23]. In the following subsections, we first use the distance (4.5) to find
an appropriate concentration parameter for the Dirichlet process. Then, we carry out a
Bayesian nonparametric chi-squared goodness-of-fit test. We also extend our method to
present a Bayesian nonparametric test of independence. The described methods will be
illustrated by some examples in Section 6.

4.1

Selection of the concentration parameter of Dirichlet process

A challenging question in Bayesian nonparametric is to determine α, the concentration parameter of the prior. To suggest an appropriate concentration parameter α, fix c and q such
that

(4.6)

P r(D(P, F0 ) ≤ c) = q,
where
D = D(P, F0 ) = α

k
X
(P (Ai ) − F0 (Ai ))2
i=1

F0 (Ai )

.

Throughout this paper, D = D(P, F0 ) denotes the prior distance. Also, let D∗ = D(Pm∗ , F0 )
∗
stands for the posterior distance as given in (4.5), replacing Hm
by F0 . We can approximate

the distribution of the prior distance D = D(P, F0 ) by the empirical distribution of N
randomly generated values from D. Thus, (4.6) can be approximated by the proportion of
17

D values that are less than or equal to c. We start with an initial value of α and then we
compute the probability (4.6). If the probability is close to the value of q, we choose α,
otherwise, we repeat this procedure by increasing or decreasing the value of α to reach the
value of q. The results of a simulation study for an illustrated example are summarized in
Table 1 in Section 6.

4.2

Goodness-of-fit test

Suppose X1 , . . . , Xm is a random sample from a distribution F . In order to test the null
hypothesis H0 : F = F0 , we place the Dirichlet process prior with parameters α and F0 on
F . Then, since under the null hypothesis, the true distribution of data is F0 , we calculate
the distance between the Dirichlet process prior and F0 . The appropriate concentration
parameter α of the Dirichlet process can be calculated by the method explained in Subsection
4.1. We follow the approach of Swartz [33]. That is, for a fixed value of q and c, we obtain α by
(4.6). Having α, we generate a random sample of size N from the Dirichlet process posterior
∗
∗
with parameters αm
and Hm
as given earlier to get N random samples of D∗ = D(Pm∗ , F0 ) as

given in Theorem 4.1. The distribution of D∗ can be estimated by the empirical distribution
of D∗ values. Hence, the posterior probability P r(D(Pm∗ , F0 ) ≤ c) can be estimated by the
proportion of D∗ which are less than or equal to c. Here, our decision making is based on
the comparison of the posterior probability and the prior probability q, where q represents
the prior belief that the underlying distribution F is practically equivalent to F0 . Usually
q = 0.5 is considered. If the empirical posterior probability P r(D(Pm∗ , F0 ) ≤ c) is less than
q, we reject the null hypothesis, otherwise there is no evidence to reject the null hypothesis.
Similar to the frequentist’s chi-squared goodness-of-fit test, we can also generalized the
test to a family of distributions. Now, consider the null hypothesis H0 : F = Fθ for some
18

θ ∈ Θ. Therefore, the true underlying distribution F is a member of a family of distributions
indexed by the parameter θ. Our approach for this case is similar to the simple hypothesis
with the addition of a prior distribution π(θ) on θ. Thus, the distance D(Pm∗ , Fθ ) depends on
the unknown parameter θ. In order to conduct the test, we first generate a random sample
from the posterior distribution of θ given X1 , . . . , Xm that is given as

g(θ | X1 , . . . , Xm ) ∝

!
m
Y
fθ (xi ) π(θ),

(4.7)

i=1

where fθ (x) is the density function corresponding to Fθ . By having a specified c and q, we
find the parameter α such that P r(D(P, Fθb) ≤ c) = q, where θb = E(θ). Then, we generate
a random sample θi∗ , i = 1, . . . , M from the posterior distribution g(θ | X1 , . . . , Xm ). We
D(Pm∗ , Fθi∗ ), i = 1, . . . , M , where Pm∗ is the posterior Dirichlet process
obtain θM in = arg min
∗
θi

with the base distribution Hθ∗i∗ as given in (2.1) with H replaced by Hθi∗ . We then generate a
sample of size N from D(Pm∗ , FθM in ). Similar to the case of testing for the simple hypothesis,
the decision is made by comparing the posterior probability P r(D(Pm∗ , FθM in ) ≤ c) and q.
Note that in the case of a non-standard distribution in (4.7), in order to sample from the
posterior distribution, we need to apply some specialized techniques such as MetropolisHastings algorithm. In Section 6, some examples with simulation study are illustrated for
the simple hypothesis H0 : F = N (0, 1) and the null hypothesis H0 : F = exp(θ) with a
Gamma (1.7, 2550) prior distribution for θ.

19

5

Bayesian nonparametric chi-squared test of independence

Here, we describe a Bayesian nonparametric chi-squared test of independence of two random
variables. The null hypothesis of the chi-squared test of independence is given as H0 :
FX,Y (x, y) = FX (x)FY (y) against the alternative H0 : FX,Y (x, y) 6= FX (x)FY (y) and hence
it examines whether there is a significant relationship between two random variables X
and Y . Suppose {Aj }j=1,...,r is a partition of the space X of the random variable X and
r

{Bk }k=1,...,s is a partition of the space Y of the random variable Y , i.e., X = ∪ Aj and
j=1

s

i.i.d

Y = ∪ Bk . Let (Xl , Yl ) ∼ F (x, y), l = 1, . . . , m be the sample data and H be a bivariate
k=1

∗
∗
distribution. Then, the Dirichlet process posterior with parameters Hm
and αm
is written as
∞
P (m)
(m)
∗
Pm∗ = pi δ(Xi∗ ,Yi∗ ) , where pi is as given in (2.2), α is replaced by αm
and (Xi∗ , Yi∗ ), i =
i=1

1, . . . , n are generated from

∗
Hm

=

m
α
H + α+m
α+m

Pm

i=1 δ(Xi ,Yi )

m

. In our new approach, we compute

the observed probability at level j of the random variable X and at level k of the random
variable Y by Pm∗ (Aj × Bk ) and the corresponding expected probability is computed as
Pm∗ (Aj × Y)Pm∗ (X × Bk ), where
Pm∗ (Aj

× Bk ) =

∞
X

(m)

pi δ(Xi∗ ,Yi∗ ) (Aj × Bk )

(5.1)

i=1

and
Pm∗ (Aj × Y) =
Pm∗ (X × Bk ) =

∞
∞
X
X
(m)
(m)
pi δ(Xi∗ ,Yi∗ ) (Aj × Y) =
pi δXi∗ (Aj )
i=1
∞
X

(m)

pi δ(Xi∗ ,Yi∗ ) (X × Bk ) =

i=1

i=1
∞
X
i=1

20

(m)

pi δYi∗ (Bk ).

(5.2)

Then, test statistic is given as
∗
D ∗ = αm

s X
r
X
(Pm∗ (Aj × Bk ) − Pm∗ (Aj × Y)Pm∗ (X × Bk ))2
Pm∗ (Aj × Y)Pm∗ (X × Bk )
k=1 j=1

(5.3)

which asymptotically converges to χ2(r−1)×(s−1) . In order to carry out the test, we proceed a
similar process as explained in Section 4 for the goodness-of-fit test. We generate a random
∗
sample of size N from the prior distance D, where D is computed by (5.3) replacing αm
by

α and the Dirichlet process posterior Pm∗ by the Dirichlet process prior P . By having a fixed
value c and a fixed probability q, an appropriate concentration parameter α is obtained by
the equation P r(D ≤ c) = q. Then, by generating a sample of size N from D∗ , we can
approximate the distribution of D∗ by the empirical distribution of D∗ values. Our decision
is made by comparing the probabilities P r(D∗ ≤ c) and q and we reject the null hypothesis
if P r(D∗ ≤ c) is less than q. An illustrative example with a simulation study is discussed in
Section 6.

6

Simulation study

This section provides some examples with simulation studies for the Bayesian nonparametric
tests described in Section 4 and 5. For all the simulations, we use the finite sum representation
to approximate the Dirichlet process as given in (2.6).
Example 6.1. We consider a Dirichlet process with the base distribution H = N (0, 1) and
n = 2000 terms in the finite sum representation (2.6). We partition the space into k = 7 bins.
Table 1 represents the probability (4.6) when F0 = N (0, 1). The probabilities are computed
for various values of α and c and for a simulation of size N = 2000. As the Table 1 shows,
21

for example, if we set q = 0.48 and c = 3, α = 10 is an appropriate concentration parameter.

α
1
10
50
100
200
300
500

c=1
0.298
0.068
0.029
0.027
0.020
0.011
0.009

P r(D(P, F0 ) < c)
c=2 c=3 c=4 c=5
0.745 0.812 0.857 0.893
0.273 0.480 0.624 0.717
0.143 0.311 0.474 0.612
0.116 0.258 0.409 0.540
0.094 0.219 0.353 0.492
0.073 0.179 0.297 0.432
0.057 0.150 0.263 0.368

c=6
0.933
0.781
0.696
0.648
0.595
0.542
0.484

Table 1: The computed the probability P r (D(P, F0 ) < c) for different choices of α and c in Example
6.1.

Example 6.2. Suppose X1 , . . . , X150 is a random sample from a standard Cauchy distribution. We want to test the null hypothesis H0 : F = N (0, 1). We divide the sample space into
k = 7 bins Ai , i = 1, . . . , 7 as given in Table 2 and P r(Ai ) shows the observed probability of
each bin. . We consider H = N (0, 1) as the base measure and n = 2000 terms in the finite
sum representation of Dirichlet process as given in (2.6). Then, an appropriate concentration
parameter α = 100 is obtained when q = 0.54 and c = 5. By sampling N = 2000 times
from the Dirichlet process posterior Pm∗ and then N = 2000 realizations of D∗ , we obtain
P r(D(Pm∗ , F0 ) ≤ c) = 0. Thus, we reject the normality hypothesis of the data. Our decision
is consistent with the classical chi-squared test which gives a p-value of 2.2×10−16 . Also, our
decision is consistent with other choices of the base measure H, since the Dirichlet process
posterior converges to the true underlying distribution as the data size increases. Table 2
illustrates the observed probabilities obtained by counting the data points in each bin and
the corresponding probabilities computed by the Dirichlet process posterior.

22

X
A1 = (−∞, −2]

A1 = (−2, −1]

A2 = (−1, 0]

A3 = (0, 1]

A4 = (1, 2]

A5 = (2, 3]

A5 = (3, ∞)

P r(Ai )

0.133

0.100

0.313

0.240

0.060

0.067

0.087

∗ (A )
Pm
i

0.072

0.131

0.342

0.310

0.069

0.030

0.046

F0 (Ai )

0.023

0.136

0.341

0.341

0.136

0.022

0.001

Table 2: The computed probabilities P r(Ai ), Pm∗ (Ai ) and F0 (Ai ) where P r(Ai ) is the observed
∗
probability obtained by counting the data points in ith bin, Pm
(Ai ) is the corresponding probability
computed by the Dirichlet process posterior for one simulation and F0 (Ai ) shows the corresponding
expected probability under the null hypothesis.

Figure 7.1 shows the Q-Q plot, the empirical distribution and the histogram of N = 2000
randomly generated from the prior distance D = D(P, F0 ) compared with a χ2(4) distribution,
respectively.

Example 6.3. (Example 3.6. Hamada et al. [17]) Suppose we have an observed data of
size m = 31 for the lifetime of the liquid crystal display (LCD) projector lamps. We want
to test if the lifetime distribution of the liquid crystal display (LCD) projector lamps is an
Exponential distribution with parameter θ > 0. That is, we want to test the null hypothesis H0 : Fθ = Exp(θ), where θ has a Gamma (1.7, 2550) prior distribution. Hence, the
posterior distribution of θ given data is a Gamma (32.7, 20457) distribution. We consider
k = 4 bins. By specifying the values q = 0.51 and c = 3, the appropriate α = 100 is
∗
as realizations from the distribution of (θ | X1 , . . . , X31 ) and
obtained. We obtain θ1∗ , . . . , θM

we get θM in = 0.00136. By generating N = 2000 times from D∗ = D(Pm∗ , FθM in ), we obtain
P r(D(Pm∗ , FθM in ) ≤ c) = 0.71. Hence, there is no evidence to reject the null hypothesis.

Example 6.4. Suppose we have a random sample (Xi , Yi ), i = 1, . . . , 150 from a bivariate

23









 0 
 10 3 
normal distribution F = N2 (µ, Σ) where µ =   and Σ = 
 . We consider five
0
3 2
levels of variable X and four levels of variable Y as given in Table 3. We want to test the
null hypothesis of independence as given in Section 5.
 0
with base distribution H = N (µ1 , Σ1 ) where µ1 = 
0

Consider a Dirichlet

 process prior

 1 0 
 and Σ1 = 
 . For q = 0.5
0 1

and c = 20, by generating N = 2000 times from D and solving the equation P r(D < c) = q,
we obtain an appropriate concentration parameter α = 100. By generating a sample of
size N = 2000 from the posterior distance D∗ , we have P r(D∗ < c) = 0. Therefore, we
reject the null hypothesis of independence. The p-value of 8.34 × 10−6 obtained by the
classical chi-squared test of independence results in the same conclusion. Table 3 represents
the probability of each category calculated by the Dirichlet process posterior.

Y

B1 = (−∞, −1]
B2 = (−1, 0]
B3 = (0, 1]
B4 = (1, ∞)

A1 = (−∞, −1]
0.076
0.075
0.072
0.014

A2 = (−1, 0]
0.069
0.031
0.047
0.061

X
A3 = (0, 1]
0.005
0.086
0.045
0.044

A4 = (1, 2]
0.066
0.063
0.048
0.025

A5 = (2, ∞)
0.000
0.006
0.043
0.125

Table 3: A sample table of probabilities computed by the Dirichlet process posterior in Example
6.4.

7

Discussion

In this paper, we proposed a Bayesian nonparametric chi-squared goodness of fit test based on
the Kullback-Leibler distance between the Dirichlet process posterior and the hypothesized
distribution. Our method proceeds by placing a Dirichlet process prior on the distribution of
observed data and computing the probability of each bin of the partition from the Dirichlet
24

process posterior. The suggested method is in contrast with the frequentist’s Pearson’s
chi-squared goodness of fit test which is based on counting the observations in each bin
of the partition. We also extended our method to present a Bayesian nonparametric test
of independence. Like the classical chi-squared test, we can generalize our goodness-of-fit
test to several variables. For categorical observations with finite many categories, placing
a Dirichlet distribution prior on the probabilities of categories and deriving the posterior
Dirichlet distribution can establish similar tests. For example, the test of independence and
conditional independence of qualitative observations follow easily.

Acknowledgments
This research was supported by grant funds from the Natural Science and Engineering Research Council of Canada.

References
[1] Al Labadi, L., 2012. On new constructive tools in bayesian nonparametric inference.
Ph.D. thesis, Université d’Ottawa/University of Ottawa.
[2] Al Labadi, L., Masuadi, E., Zarepour, M., 2014. Two-sample bayesian nonparametric
goodness-of-fit test. arXiv:1411.3427.

25

[3] Al Labadi, L., Zarepour, M., 2013. A bayesian nonparametric goodness of fit test for
right censored data based on approximate samples from the beta-stacy process. Canadian Journal of Statistics 41 (3), 466–487.
[4] Al Labadi, L., Zarepour, M., 2014. Goodness-of-fit tests based on the distance between
the dirichlet process and its base measure. Journal of Nonparametric Statistics 26 (2),
341–357.
[5] Berger, J. O., Guglielmi, A., 2001. Bayesian and conditional frequentist testing of a
parametric model versus nonparametric alternatives. Journal of the American Statistical
Association 96 (453), 174–184.
[6] Best, D., Rayner, J., 1981. Are two classes enough for the χ2 goodness-of-fit test?
Statistica Neerlandica 35 (3), 157–163.
[7] Billingsley, P., 2013. Convergence of Probability Measures. John Wiley & Sons.
[8] Bondesson, L., 1982. On simulation from infinitely divisible distributions. Advances in
Applied Probability 14 (4), 855–869.
[9] Carota, C., Parmigiani, G., 1994. On Bayes factors for nonparametric alternatives.
Institute of Statistics and Decision Sciences, Duke University.
[10] D’Agostino, R. B., 1986. Goodness-of-Fit Techniques. Marcel Dekker, New York.
[11] Dahiya, R. C., Gurland, J., 1973. How many classes in the pearson chi-square test?
Journal of the American Statistical Association 68 (343), 707–712.
[12] Escobar, M. D., West, M., 1995. Bayesian density estimation and inference using mixtures. Journal of the American Statistical Association 90 (430), 577–588.
26

[13] Ferguson, T. S., 1973. A bayesian analysis of some nonparametric problems. Annals of
Statistics 1 (2), 209–230.
[14] Ferguson, T. S., Klass, M. J., 1972. A representation of independent increment processes
without gaussian components. Annals of Mathematical Statistics 43 (5), 1634–1643.
[15] Florens, J.-P., Richard, J.-F., Rolin, J. M., 1996. Bayesian encompassing specification
tests of a parametric model against a nonparametric alternative. Tech. Rep. 9608, Université catholique de Louvain, Institut de Statistique.
[16] Ghosal, S., 2010. The dirichlet process, related priors and posterior asymptotics. In:
Bayesian Nonparametrics. Cambridge University Press, Cambridge, pp. 35–79.
[17] Hamada, M. S., Wilson, A., Reese, C. S., Martz, H., 2008. Bayesian Reliability. Springer,
New York.
[18] Hamdan, M., 1963. The number and width of classes in the chi-square test. Journal of
the American Statistical Association 58 (303), 678–689.
[19] Holmes, C. C., Caron, F., Griffin, J. E., Stephens, D. A., 2015. Two-sample bayesian
nonparametric hypothesis testing. Bayesian Analysis 10 (2), 297–320.
[20] Hsieh, P.-H., 2013. A nonparametric assessment of model adequacy based on kullbackleibler divergence. Statistics and Computing 23 (2), 149–162.
[21] Ishwaran, H., Zarepour, M., 2002. Exact and approximate sum representations for the
dirichlet process. Canadian Journal of Statistics 30 (2), 269–283.
[22] James, L. F., 2008. Large sample asymptotics for the two-parameter poisson–dirichlet
process. Vol. 3. Institute of Mathematical Statistics, pp. 187–199.
27

[23] Johnson, V. E., 2004. A bayesian χ2 test for goodness-of-fit. Annals of Statistics 32 (6),
2361–2384.
[24] Johnson, V. E., 2007. Bayesian model assessment using pivotal quantities. Bayesian
Analysis 2 (4), 719–733.
[25] Koehler, K. J., Gan, F., 1990. Chi-squared goodness-of-fit tests: Cell selection and
power. Communications in Statistics-Simulation and Computation 19 (4), 1265–1278.
[26] Kullback, S., Leibler, R. A., 1951. On information and sufficiency. Annals of Mathematical Statistics 22 (1), 79–86.
[27] Lo, A. Y., 1984. On a class of bayesian nonparametric estimates: I. density estimates.
Annals of Statistics 12 (1), 351–357.
[28] Lo, A. Y., 1987. A large sample study of the bayesian bootstrap. Annals of Statistics
15 (1), 360–375.
[29] Mann, H., Wald, A., 1942. On the choice of the number of class intervals in the application of the chi-square test. Annals of Mathematical Statistics 13 (3), 306–317.
[30] Muliere, P., Tardella, L., 1998. Approximating distributions of random functionals of
ferguson-dirichlet priors. Canadian Journal of Statistics 26 (2), 283–297.
[31] Neal, R. M., 1992. Bayesian mixture modeling. In: Maximum Entropy and Bayesian
Methods. Springer, pp. 197–211.
[32] Quine, M., Robinson, J., 1985. Efficiencies of chi-square and likelihood ratio goodnessof-fit tests. Annals of Statistics 13 (2), 727–742.

28

[33] Swartz, T., 1999. Nonparametric goodness-of-fit. Communications in Statistics-Theory
and Methods 28 (12), 2821–2841.
[34] Tokdar, S. T., Martin, R., 2011. Bayesian test of normality versus a dirichlet process
mixture alternative. arXiv:1108.2883.
[35] Verdinelli, I., Wasserman, L., 1998. Bayesian goodness-of-fit testing using infinitedimensional exponential families. Annals of Statistics 26 (4), 1215–1241.
[36] Viele, K., 2000. Evaluating fit using dirichlet processes. Tech. Rep. 384, Department of
Statistics, University of Kentucky.
[37] Watson, G., 1957. The χ2 goodness-of-fit test for normal distributions. Biometrika,
336–348.
[38] Williams Jr, C. A., 1950. The choice of the number and width of classes for the chisquare test of goodness-of-fit. Journal of the American Statistical Association 45 (249),
77–86.
[39] Zarepour, M., Al Labadi, L., 2012. On a rapid simulation of the dirichlet process.
Statistics & Probability Letters 82 (5), 916–924.

Appendix - Proofs of Theoretical Results
Proof of Lemma 3.1:
Suppose that the sample space is partitioned as x(1) < · · · < x(n+1) such that x(i) < θ(i) <
x(i+1) , i = 1, . . . , n. By definition of the Kullback-Leibler distance, we have

29

DKL (Pn


n
X
k F) =
4Pn (xi ) log
i=1

4Pn (xi )
4F (xi )/4xi





n
n
X
X
4F (xi )
=
4Pn (xi ) log(4Pn (xi )) −
4Pn (xi ) log
4xi
i=1
i=1


n
n
X
X
4F (xi )
=
pi,n log(pi,n ) −
pi,n log
4xi
i=1
i=1


n
X
4F (xi )
pi,n log
,
= −H(p) −
4x
i
i=1

(7.1)

where 4F (xi ) = F (x(i+1) ) − F (x(i) ), 4xi = x(i+1) − x(i) ,
n
P
pi,n = Pn (x(i+1) ) − Pn (x(i) ) = Pn (θ(i) ) and H(p) = − pi,n log(pi,n ) is the entropy of Pn .
i=1

Similarly, we get

n
X
DKL (F k Pn ) = −H(q) −
qi log(pi,n ),

(7.2)

i=1

where qi =

4F (xi )
4xi

and H(q) = −

n
P

qi log qi .

i=1

Proof of Theorem 3.1 and Remark 3.1:
We have (p1,n , . . . , pn,n ) ∼ Dir(α/n, . . . , α/n). Thus, pi,n ∼ Beta( αn , α(1− n1 )), i = 1, . . . , n
and all computations for the mean and variance simply follow.
Proof of Theorem 4.1:
We basically mimic the proof for the asymptotic frequentist’s chi-squared goodness-of-fit
test. Define

30

k
∗
X
(Pm∗ (Ai ) − Hm
(Ai ))2
D∗ = (α + m)
.
∗ (A )
H
i
m
i=1

(7.3)

T
= (Y1,m , . . . , Yk,m ) = (Pm∗ (A1 ), . . . , Pm∗ (Ak )) and
Let Ym
∗
∗
T
(Ak )). By Lemma 4.1, as m → ∞,
(A1 ), . . . , Hm
= (v1,m , . . . , v k,m ) = (Hm
vm

√
d
α + m(Ym − vm )T → Nk (0, Σ).

(7.4)

In here, Σ = (σij )k×k is the covariance matrix with σii2 = var(Yi,m ) = F (Ai )(1 − F (Ai )), i =
1, . . . , k and σij = cov(Yi,m , Yj,m ) = −F (Ai )F (Aj ). Then, (7.3) can be written as

D∗ = (α + m)(Ym − vm )T Σ−1 (Ym − vm ).

(7.5)

Note that the sum of the jth column of Σ is F (Aj )−F (Aj )(F (A1 ) + · · · + F (Ak )) = 0, that
implies the sum of the rows of Σ is the zero vector, therefore Σ is not invertible. To avoid
∗
∗T
be the vector
= (Y1,m , . . . , Yk−1,m ). Let Ym
dealing with this singular matrix, we define Ym
∗
is the
consisting of the first k − 1 components of Ym . Then, the covariance matrix of Ym
∗T
upper-left (k − 1) × (k − 1) sub-matrix of Σ which is denoted by Σ∗ . Similarly, let vm
∗T
denotes the vector vm
= (v1,m , . . . , v k−1,m ). It can be verified simply that Σ∗ is invertible.

Furthermore, (7.5) can be rewritten as

∗
∗ T
∗
∗
D∗ = (α + m)(Ym
− vm
) (Σ∗ )−1 (Ym
− vm
).

Define

ZTm =

√
∗
∗ T
α + m(Σ∗ )−1/2 (Ym
− vm
) .
31

(7.6)

d

The central limit theorem implies ZTm → Nk−1 (0, I). By definition, the χ2(k−1) distribution
is the distribution of the sum of the squares of k−1 independent standard normal random
variables. Therefore,

d

D∗ = ZTm Zm → χ2(k−1) .

32

1.0
0.8
0

5

10
χ2(4)

15

20

50
0

5

10

15

20

25

30

d
χ2(4)

0

0.4
0.0

0.2

F(x)

100

0.6

20
15
10
5
0

d

150

25

d
χ2(4)

0

5

10

15

20

25

x

Figure 7.1: (Left) The Q-Q plot of N = 2000 realizations of D = D(P, H) with α = 100,
H = N (0, 1), k = 5 and n = 3000 versus a χ2(4) distribution. (Middle) The empirical
distribution function of D values and the cdf of a χ2(4) distribution. (Right) The histogram
of D values and the pdf of a χ2(4) distribution.

33

