3
ChiSquare GoodnessofFit Test
Given an iid sample
1
,
,
n
X
X
K
, we want to test:
H
0
:
The sample
1
,
,
n
X
X
K
comes from the hypothesized theoretical
distribution function
ˆ
F
, against the alternative
H
1
:
It does not.
We start by preparing the observed and expected frequency distributions.
j
Interval,
1
[
,
)
j
j
a
a

Observed
frequency,
j
N
Expected
frequency,
j
np
1
0
1
[
,
)
a
a
1
N
1
np
2
1
2
[
,
)
a
a
2
N
2
np
…
…
…
…
…
…
…
…
k
1
[
,
)
k
k
a
a

k
N
k
np
Total =
n
j
p
needed to calculate the expected frequencies are found as follows.
1
ˆ
( )
j
j
a
j
a
p
f x dx

=
∫
,
1,
,
j
k
=
K
, if
X
is continuous
1
ˆ(
)
j
i
j
j
i
a
x
a
p
p x

≤
<
=
∑
,
1,
,
j
k
=
K
, if
X
is discrete
where
ˆ
f
or
ˆ
p
represents the fitted distribution.
The test statistic is
2
2
1
(
)
k
j
j
j
j
N
np
np
χ
=

=
∑
.
Reject H
0
if
2
2
, 1
df
α
χ
χ

where
1
df
k
=

if distribution parameters are known,
1
df
k
p
=


if
p
distribution parameters are estimated from the same sample.
2
, 1
df
α
χ

α