example3.mws

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;

n := 21

var := 100

alpha := .5e-1

> L := var*ChisquareP(n-1, alpha/2)/sigma^2;

L := 959.0777392*1/(sigma^2)

> U := var*ChisquareP(n-1, 1-alpha/2)/sigma^2;

U := 3416.960690*1/(sigma^2)

> K := 1-ChisquareCDF(n-1,U) + ChisquareCDF(n-1,L);

K := 1+1.*(.3417644210e24*exp(-1708.480345*1/(sigma...
K := 1+1.*(.3417644210e24*exp(-1708.480345*1/(sigma...
K := 1+1.*(.3417644210e24*exp(-1708.480345*1/(sigma...
K := 1+1.*(.3417644210e24*exp(-1708.480345*1/(sigma...
K := 1+1.*(.3417644210e24*exp(-1708.480345*1/(sigma...
K := 1+1.*(.3417644210e24*exp(-1708.480345*1/(sigma...
K := 1+1.*(.3417644210e24*exp(-1708.480345*1/(sigma...

> P4 := plot(K, sigma=0..20): P4;

[Maple Plot]

>

> display(P4);

[Maple Plot]

> Alpha := [0.005, 0.01, 0.025, 0.05, 0.1, 0.2];

Alpha := [.5e-2, .1e-1, .25e-1, .5e-1, .1, .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});

[Maple Plot]

> display([P1,P2,P3,P4,P5,P6], insequence = true);

[Maple Plot]

>

> alpha := 0.05;

alpha := .5e-1

> 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});

[Maple Plot]

> display([Q1,Q2,Q3,Q4,Q5,Q6], insequence = true);

[Maple Plot]