Probability Distribution Function and Shape
The Chi-Square Distribution
A random variable has a Chi-square distribution with
degrees of freedom (
(
) ) if and only if its probability density is given by
for
x
> 0
f ( x ) =
0 elsewhere.
The following code will draw the density function for the
(
) distribution for
. However, you are encouraged to try other values of
.
> restart;
> with(plots):
> nu:=5;
> f:=x->ChisquarePDF(nu,x);
> plot(f(x),x=0..20);
To see the effect of
on the shape of the
(
) distribution, the following animation will draw a series of PDFs as
varies from 1 to 21 by increments of 1. What happens as
increases?
> nu[0]:=1; nu_step:=1;
> for n from 0 to 20 do
> density[n]:=plot(ChisquarePDF(nu[0]+n*nu_step,x),x=0..35):
> num:=convert(evalf(nu[0]+n*nu_step,3),string):
> tracker[n]:=textplot([18,0.3,`nu is `.num],color=blue);
> P[n]:=display({density[n],tracker[n]}):
> od:
> display([seq(P[n], n=0..20)], insequence=true);
>
This next bit of code will animate the CDF of a
(
) through the same values of
as the previous example.
What happens to the CDF as
increases?
> nu[0]:=1; nu_step:=1;
> for n from 0 to 20 do
> density[n]:=plot(ChisquareCDF(nu[0]+n*nu_step,x),x=0..35):
> num:=convert(evalf(nu[0]+n*nu_step,3),string):
> tracker[n]:=textplot([18,0.3,`nu is `.num],color=blue);
> P[n]:=display({density[n],tracker[n]}):
> od:
> display([seq(P[n], n=0..20)], insequence=true);
>