Example 3: The Power Function of a Statistical Test
by Zavan Karian
> restart: with(plots,display): libname:="C:/mylib/statistics",libname: with(stat):
> n := 21; var := 100; alpha := 0.05;
> L := var*ChisquareP(n-1, alpha/2)/sigma^2;
> U := var*ChisquareP(n-1, 1-alpha/2)/sigma^2;
> K := 1-ChisquareCDF(n-1,U) + ChisquareCDF(n-1,L);
> P4 := plot(K, sigma=0..20): P4;
>
> display(P4);
> Alpha := [0.005, 0.01, 0.025, 0.05, 0.1, 0.2];
> for i from 1 to 6 do
> alpha := Alpha[i];
> L := var*ChisquareP(n-1, alpha/2)/sigma^2;
> U := var*ChisquareP(n-1, 1-alpha/2)/sigma^2;
> K := 1-ChisquareCDF(n-1,U) + ChisquareCDF(n-1,L):
> P||i := plot(K, sigma=0..20):
> od:
> #interface(plotdevice=postscript, plotoutput=Fig3a);
> display({P1,P2,P3,P4,P5,P6});
> display([P1,P2,P3,P4,P5,P6], insequence = true);
>
> alpha := 0.05;
> for i from 1 to 6 do
> n := 1+4*i:
> L := var*ChisquareP(n-1,alpha/2)/sigma^2:
> U := var*ChisquareP(n-1,1-alpha/2)/sigma^2:
> K := 1-ChisquareCDF(n-1,U) + ChisquareCDF(n-1,L):
> Q||i := plot(K, sigma=0..20):
> od:
> #interface(plotdevice=postscript, plotoutput=Fig3b);
> display({Q1,Q2,Q3,Q4,Q5,Q6});
> display([Q1,Q2,Q3,Q4,Q5,Q6], insequence = true);