Some STA205 demos involving Chi-Squares

Andy Long

Here’s the chi-square density (pdf) function, for 3 degrees of freedom (df), as well as the cumulative density (cdf -- the sum of the area to a given value):

Mathematica already has this built in, of course: you just can’t see how it’s made.

Plot[PDF[ChiSquareDistribution[3],x],{x,0,6}]
Plot[CDF[ChiSquareDistribution[3],x],{x,0,6}]

To illustrate df’s role in the shape of a chi-square:

Manipulate[
Module[{p1,p2},
p1=Plot[PDF[ChiSquareDistribution[df],x],{x,0,2*df},PlotRange->All,Filling->Axis,PlotLabel->StringJoin[{"df=",TextString[df]}]]
(* p2=Plot[CDF[ChiSquareDistribution[df],x],{x,0,df},PlotRange->All];
Show[p1,p2] *)
],
{df,2,30,1}]