example7.mws

Example 7: Relationships Between Random Variables

by Zavan Karian

> restart: with(plots, display): libname:="C:/mylib/statistics",libname: with(stat):

> Z1 := NormalS(0,1,500):

> Z1H := Histogram(Z1, -4..4, 9):

> N01 := plot(NormalPDF(0,1,x), x=-4..4):

> display({Z1H, N01});

[Maple Plot]

> Y := [seq(Z1[i]^2, i=1..500)]:

> YH := Histogram(Y, 0..12, 16):

> CH1 := plot(ChisquarePDF(1,x), x=0..12):

> #interface(plotdevice=postscript, plotoutput=Fig7a);

> display({YH, CH1});

[Maple Plot]

>

> Z2 := NormalS(0,1,500):

> Z3 := NormalS(0,1,500):

> Y := [seq(Z1[i]^2+Z2[i]^2+Z3[i]^2, i=1..500)]:

> YH := Histogram(Y, 0..18, 24):

> CH3 := plot(ChisquarePDF(3,x), x=0..12):

> #interface(plotdevice=postscript, plotoutput=Fig7b);

> display({YH, CH3});

[Maple Plot]

>

> Z := [seq(NormalS(37, 16, 3), i=1..200)]:

> S := [seq(sum( (Z[i][j]-37)^2/16, j=1..3), i=1..200)]:

> T := [seq(sum( (Z[i][j]-Mean(Z[i]))^2/16, j=1..3), i=1..200)]:

> SH := Histogram(S, 0..20, 16):

> TH := Histogram(T, 0..20, 16):

> CH2 := plot(ChisquarePDF(2,x), x=0..20):

> CH3 := plot(ChisquarePDF(3,x), x=0..20):

> #interface(plotdevice=postscript, plotoutput=Fig8a);

> display({CH3, SH});

[Maple Plot]

> #interface(plotdevice=postscript, plotoutput=Fig8b);

> display({CH2, TH});

[Maple Plot]