9.1 카이제곱 분포의 자유도
9.1.1 카이제곱 분포의 정의
앞 장에 이미 나왔지만, 카이제곱 분포를 따르는 확률변수는 다음과 같이 정의에 따라 생성할 수 있다.
\[Z_i \stackrel{i.i.d}{\sim} N(0, 1^2)\] \[{}\] \[V = Z_1^2 + Z_2^2 + \cdots + Z_k^2 \sim {\chi}^2(k)\]
\(Z_i\)s are independent and identically distributed(i.i.d.).
9.1.2 Setting
= 10 # Degree of Freedom, Number of Zs to be added for Chi-square variable V
Df = 5000 # Number of Chi-square Variables (Vs) nV
9.1.3 Generate Zs (standard normal distribution) and Vs (chi-square distribution)
9.1.4 Get theoretical values
= seq(0, 30, length.out=101)
x = dchisq(x, df=Df)
y1 = dchisq(x, df=Df - 1) y2
9.1.5 Plot
# dev.new(width=14, height=7)
plot(x, y2, type="l", col="red", ylab="Density") # This is taller, so plot first
lines(density(rV2), lty=2, col="red")
lines(x, y1)
lines(density(rV), lty=2)
legend(17, 0.1,
c("Df=10 Theoretical", "Df=10 Simulation", "Df=9 Theoretical", "Df=9 Simulation"),
lty=c(1,2,1,2), col=c(1,1,2,2))
Figure 9.1: Degree of freedom and Chi-square distribution