A random variable \(X\) is said to have a chi-square distribution with n degrees of freedom if it has density
\[\frac{1}{\Gamma(n/2)2^{n/2}}x^{n/2-1}e^{-x/2}\]
Let \(Z\sim N(0,1)\) and let \(X=Z^2\), then
\[ \begin{aligned} &F_X(x) =P(X<x) = P(Z^2<x) = \\ &P(-\sqrt{x}<Z<\sqrt{x}) = \\ &\int_{-\sqrt{x}}^{\sqrt{x}} \frac1{\sqrt{2\pi}} e^{-t^2/2}dt \\ &f_X(x) = \frac{d F_x(x)}{dx} = \frac{d }{dx} \int_{-\sqrt{x}}^{\sqrt{x}} \frac1{\sqrt{2\pi}} e^{-t^2/2}dt=\\ &\frac1{\sqrt{2\pi}} e^{-(\sqrt{x})^2/2} \frac{1}{2\sqrt{x}}- \frac1{\sqrt{2\pi}} e^{-(-\sqrt{x})^2/2}\frac{-1}{2\sqrt{x}} = \\ &\frac1{\sqrt{2\pi}}\frac{1}{\sqrt{x}} e^{-x/2} =\\ &\frac{1}{\Gamma(1/2)2^{1/2}}x^{1/2-1}e^{-x/2} \end{aligned} \]
and so \(X\sim \chi^2(1)\).
Say \(X\) has a chi-square distribution with n df, then
proof
\[ \begin{aligned} &E[X^k] =\int_0^\infty x^k \frac{1}{\Gamma(n/2)2^{n/2}}x^{n/2-1}e^{-x/2} dx =\\ &\frac{1}{\Gamma(n/2)2^{n/2}}\int_0^\infty x^{k+n/2-1}e^{-x/2} dx = \\ &\frac{\Gamma((2k+n)/2)2^{(2k+n)/2}}{\Gamma(n/2)2^{n/2}}\int_0^\infty \frac{1}{\Gamma((2k+n)/2)2^{(2k+n)/2}} x^{(2k+n)/2-1}e^{-x/2} dx = \\ &\frac{\Gamma(k+n/2)2^{k+n/2}}{\Gamma(n/2)2^{n/2}} = \\ &\frac{(k+n/2-1)(k+n/2-2)..n/2\Gamma(n/2)2^{k}}{\Gamma(n/2)} = \\ &(k+n/2-1)(k+n/2-2)..(n/2)2^k\\ &E[X] = n/2\times 2 =n \\ &var(X) = E[X^2]-E[X]^2= \\ &(n/2+1)(n/2)2^2 - n^2 = n^2+2n-n^2=2n \end{aligned} \] iii.
\[ \begin{aligned} &\psi_x(t) = E[e^{tX}] = \\ &\int_0^\infty e^{tx} \frac{1}{\Gamma(n/2)2^{n/2}}x^{n/2-1}e^{-x/2} dx = \\ &\int_0^\infty \frac{1}{\Gamma(n/2)2^{n/2}}x^{n/2-1}e^{-(1/2-t)x} dx = \\ &(1-2t)^{-n/2}\int_0^\infty \frac{1}{\Gamma(n/2)[(1-2t)^{-1}]^{n/2}}x^{n/2-1}e^{-(\frac{1-2t}2)x} dx = \\ &(1-2t)^{-n/2} \end{aligned} \]
Let \(X,Y\) have independent chi-square distributions with n and m degrees of freedom, respectively, then
\[ \begin{aligned} &\psi_{X+Y}(t)=\psi_{X}(t)\psi_{Y}(t) = \\ &(1-2t)^{-n/2}(1-2t)^{-m/2} = (1-2t)^{-(n+m)/2} \end{aligned} \]
and so \(X+Y\sim \chi^2(n+m)\). Therefore if \(\pmb{Z}=(Z_1\text{ ... }Z_n)', Z_i\sim N(0,1)\) and independent, then
\[\pmb{Z'Z}\sim \chi^2(n)\]
Now say \(X_i\sim N(\mu_i, 1)\), independent, and let \(\pmb{X}=(X_1\text{ ... }X_n)'\) and \(\pmb{\mu}=(\mu_1\text{ ... }\mu_n)'\). Therefore
\[\pmb{(X-\mu)'(X-\mu)}\sim \chi^2(n)\]
Let \(Y\sim N(\mu,1)\) and let \(X=Y^2\), then
\[ \begin{aligned} &F_X(x) =P(X<x) = P(Y^2<x) = \\ &P(-\sqrt{x}<Z<\sqrt{x}) = \\ &\int_{-\sqrt{x}}^{\sqrt{x}} \frac1{\sqrt{2\pi}} e^{-(t-\mu)^2/2}dt \\ &f_X(x) = \frac{d F_x(x)}{dx} = \frac{d }{dx} \int_{-\sqrt{x}}^{\sqrt{x}} \frac1{\sqrt{2\pi}} e^{-(t-\mu)^2/2}dt=\\ &\frac1{\sqrt{2\pi}} e^{-(\sqrt{x}-\mu)^2/2} \frac{1}{2\sqrt{x}}- \frac1{\sqrt{2\pi}} e^{-(-\sqrt{x}-\mu)^2/2}\frac{-1}{2\sqrt{x}} = \\ &\frac1{\sqrt{2\pi}}\frac{1}{\sqrt{x}} \left[e^{-(\sqrt{x}-\mu)^2/2}+e^{-(-\sqrt{x}-\mu)^2/2}\right] =\\ &\frac1{\sqrt{2\pi}}\frac{1}{\sqrt{x}} \left[e^{-(x-2\sqrt{x}\mu+\mu^2)/2}+e^{-(x+2\sqrt{x}\mu+\mu^2)/2}\right] =\\ &\frac{1}{\Gamma(1/2)2^{1/2}}x^{1/2-1}e^{-x/2} \left[e^{\sqrt{x}\mu}+e^{-\sqrt{x}\mu}\right]e^{-\mu^2/2} =\\ &g(x,1)\left[e^{\sqrt{x}\mu}+e^{-\sqrt{x}\mu}\right]e^{-\mu^2/2} \end{aligned} \] where g is the density of a chi-square distribution with 1 degree of freedom.
More generally we have
Let \(X_i\sim N(\mu_i, 1)\),i=1,..,n and independent, then the distribution of \(\pmb{X'X}\) is called a non-central chi-square distribution with n degrees of freedom and non-centrality parameter \(\lambda\) where
\[\lambda=\frac12 \sum_{i=1}^n \mu_i^2 = \pmb{\mu'\mu}/2\]
We write \(\pmb{X'X}\sim \chi^2(n, \lambda)\)
Note
\[ \begin{aligned} &E[\sum_{i=1}^n (X_i-\mu_i)^2] = \\ &\sum_{i=1}^n E[(X_i-\mu_i)^2] = \\ &\sum_{i=1}^n var(X_i) = n\\ &E[\sum_{i=1}^n X_i^2] = \\ &\sum_{i=1}^n E[X_i^2] = \\ &\sum_{i=1}^n (var(X_i)+E[X_i]^2) = \\ &\sum_{i=1}^n (1+\mu_i^2) = \\ &n+\sum_{i=1}^n \mu_i^2 = n+2\lambda\\ \end{aligned} \]
We can use R to calculate values for the non-central chisquare distribution, however a bit of care: R uses \(\lambda=\pmb{\mu'\mu}\) for the definition of the non-centrality parameter.
f=function(x) dchisq(x, 5)
f1=function(x) dchisq(x, 5, ncp = 4)
curve(f, 0, 20, lwd=2, col="blue")
curve(f1, 0, 20, lwd=2, col="red", add=TRUE)
let’s check with a simulation:
B=1e4
x=rnorm(B,1)
y=rnorm(B,2)
u=x^2+y^2
lambda=(1^2+2^2)
round(c(sum(u<5)/B, pchisq(5,2,lambda)), 4)
## [1] 0.4091 0.4082
Say \(X\sim \chi^2(n, \lambda)\), then
proof i and ii follow from the calculation above, iii uses the theorem from the last section.
If \(X_1\sim \chi^2(n_1, \lambda_1),..,X_k\sim \chi^2(n_k, \lambda_k)\) and independent, then \(\sum_{i=1}^k X_i\sim \chi^2(\sum_{i=1}^k n_i, \sum_{i=1}^k\lambda_i)\)
proof similar to the corresponding theorem for chi-square distributions above.
The random variable X is said to have an F distribution with n and m degrees of freedom if it has density
\[f(x\vert n,m)=\frac{\Gamma((n+m)/2)}{\Gamma(n/2)\Gamma(m/2)}(\frac{n}m)^{n/2}\frac{x^{n/2-1}}{(1+nx/m)^{(n+m)/2}}\]
Say \(X\sim \chi^2(n),Y\sim \chi^2(m)\), independent, then \(F=\frac{X/n}{Y/m}\sim F(n,m)\)
proof
\[ \begin{aligned} &F_Z(z) =P(Z<z) =P((X/n)/(Y/m)<z) = \\ &P(X<\frac{nz}{m}Y) = \\ &\int_{-\infty}^\infty P(X<\frac{nz}{m}Y\vert Y=y)f_Y(y)dy = \\ &\int_{-\infty}^\infty P(X<\frac{nz}{m}y)f_Y(y)dy = \\ &\int_{-\infty}^\infty F_X(\frac{nz}{m}y)f_Y(y)dy \end{aligned} \] so
\[ \begin{aligned} &f_Z(z) =\frac{d}{dz}F_Z(z)= \\ &\frac{d}{dz} \int_{-\infty}^\infty F_X(\frac{nz}{m}y)f_Y(y)dy = \\ &\int_{-\infty}^\infty \frac{d}{dz} F_X(\frac{nz}{m}y)f_Y(y)dy = \\ &\int_{-\infty}^\infty f_X(\frac{n}{m}yz)\frac{n}{m}yf_Y(y)dy = \\ &\int_{-\infty}^\infty \frac1{\Gamma(n/2)2^{n/2}}(\frac{n}{m}yz)^{n/2-1}e^{-(n/m)yz/2}\frac{n}{m}y\frac1{\Gamma(m/2)2^{m/2}}y^{m/2-1}e^{-y/2}dy=\\ &\frac1{\Gamma(n/2)2^{n/2}}(\frac{n}{m}z)^{n/2-1}(\frac{n}{m}z)^{n/2-1}\frac1{\Gamma(m/2)2^{m/2}}\int_{-\infty}^\infty y^{(n+m)/2-1}e^{y/[2/(1+nz/m)]}dy=\\ &\frac{\Gamma((n+m)/2)}{\Gamma(n/2)\Gamma(m/2)}z^{n/2-1}(\frac{n}{m})^{n/2}\left(\frac1{1+nz/m}\right)^{(n+m)/2}\cdot\\ &\int_{-\infty}^\infty \frac1{\Gamma((n+m)/2)\left(\frac2{1+nz/m}\right)^{(n+m)/2}}y^{(n+m)/2-1}e^{y/[2/(1+nz/m)]}dy=\\ &\frac{\Gamma((n+m)/2)}{\Gamma(n/2)\Gamma(m/2)}z^{n/2-1}(\frac{n}{m})^{n/2}\left(\frac1{1+nz/m}\right)^{(n+m)/2} \end{aligned} \] because the integrand is the density of a \(Gamma((n+m)/2, (2/(1+nz/m))\) density and so integrates to 1.
Say \(X\sim F(n,m)\), then
proof omitted
Say \(X\sim \chi^2(n,\lambda),Y\sim \chi^2(m)\), independent, then the random variable \(F=\frac{X/n}{Y/m}\) is said to have an non-central F distribution with n and m degrees of freedom and non-centrality parameter \(\lambda\).
Say \(X\sim F(n,m,\lambda)\), then \(E[X]=\frac{m}{m-2}(1+2\lambda/n)\)
proof omitted
We can use R to calculate values for the non-central F distribution:
f=function(x) df(x, 3, 5)
f1=function(x) df(x, 3, 5, ncp = 4)
curve(f, 0, 10, lwd=2, col="blue")
curve(f1, 0, 10, lwd=2, col="red", add=TRUE)
Say \(Z\sim N(0, 1),Y\sim \chi^2(n)\), independent, then the random variable \(T=\frac{Z}{\sqrt{Y/m}}\) is said to have a Student’s t distribution with n degrees of freedom. It has density
\[f(x\vert n)=\frac{\Gamma((n+1)/2)}{\Gamma(n/2)}\frac{1}{\sqrt{\pi n}}\frac{1}{(1+x^2/n)^{(n+1)/2}}\]
Say \(X\sim N(\mu,1),Y\sim \chi^2(n)\), independent, then the random variable \(T=\frac{X}{\sqrt{Y/n}}\) is said to have a non-central t distribution with n degrees of freedom and non-centrality parameter \(\mu\).
Note that if \(X\sim N(\mu,\sigma^2),Y\sim \chi^2(n)\), independent, then \(T=\frac{X/\sigma}{\sqrt{Y/n}}\sim t(n, \mu/\sigma)\)
We can use R to calculate values for the non-central F distribution:
f=function(x) dt(x, 3)
f1=function(x) dt(x, 3, ncp = 1)
curve(f, -5, 5, lwd=2, col="blue")
curve(f1, -5, 5, lwd=2, col="red", add=TRUE)
Say \(X\sim t(n)\), then \(X^2\sim F(1, n)\).
proof
Let \(Z\sim N(0,1)\), \(T\sim \chi^2(n)\) and \(Y\sim F(n,m)\), then
\[ \begin{aligned} &F_{X^2}(x) =P(X^2<x) = P\left(\left[\frac{Z}{\sqrt{T/n}}\right]^2<x\right) = \\ &P\left(\frac{Z^2}{T/n}<x\right) = P\left(\frac{Z^2/1}{T/n}<x\right) =\\ &P(Y<x)=F_Y(x) \end{aligned} \]
Say \(X\sim t(5)\) and \(Y\sim F(1,5)\)
\[P(X^2<4)=P(-2<X<2)=2P(X< 2)-1\]
pf(4, 1, 5)
## [1] 0.8980605
2*pt(2,5)-1
## [1] 0.8980605