>    restart:
read `C:\\Tanis-Hogg\\Maple Examples\\stat.m`:
read `C:\\Tanis-Hogg\\Maple Examples\\HistogramFill.txt`:
read `C:\\Tanis-Hogg\\Maple Examples\\ScatPlotCirc.txt`:
read `C:\\Tanis-Hogg\\Maple Examples\\ScatPlotPoint.txt`:
with(plots):

Elliot Tanis
June 12, 2006
Figures 5.4-2(a) and 5.4-2(b)  (Fig5_4-2.mws)

Figures 5.4-2(a) and 5.4-2(b) Simulation of observations from an exponential distribution.

>    randomize():

>    for k from 1 to 1000 do
X := [seq(-ln(1 - rng()), k = 1 .. 16)]:
TT[k] := (Mean(X) - 1)/(StDev(X)/4):
od:
T := [seq(TT[k], k = 1 .. 1000)]:

>    tbar := Mean(T);

tbar := -.3028968080

>    s := StDev(T);

s := 1.333411788

>    Min(T), Max(T);

-8.454318360, 3.670801478

>    xtics := [seq(-7 + k*0.5, k = 0 .. 21)]:
ytics := [seq(0.05*k, k = 1 .. 8)]:
P1 := HistogramFill(T, -6.5 .. 3.5, 20):
P2 := plot([[0,0],[0,0]], x = -6.5 .. 3.5, y = 0 .. 0.41, xtickmarks=xtics, ytickmarks=ytics, labels=[``,``]):
display({P1, P2});

`WARNING: There are`, 3, ` data points out of plot range.`

[Maple Plot]

Similar to Figure 5.4-2(a)

>    #zper := [seq(NormalP(0, 1, k/1001), k = 1 .. 1000)]:
k := 'k':
for k from 1 to 500 do
  zp[k] := NormalP(0, 1, k/1001):
  zp[1000-k+1] := -zp[k]:
od:

>    zper := [seq(zp[k], k = 1 .. 1000)]:

>    Torder := sort(T):

>    ScatPlotPoint(Torder, zper);

[Maple Plot]

Similar to Figure 5.4-2(b)

>   

>    X := [seq(-ln(1 - rng()) + 9, k = 1 .. 16)];
Mean(X);
StDev(X);

X := [15.04570335, 10.95541035, 10.29295850, 9.077001231, 9.341020304, 9.269759934, 9.093358330, 10.43225069, 10.51313716, 9.889226946, 9.715302612, 9.813070696, 9.442952385, 9.752484376, 12.99750132, ...
X := [15.04570335, 10.95541035, 10.29295850, 9.077001231, 9.341020304, 9.269759934, 9.093358330, 10.43225069, 10.51313716, 9.889226946, 9.715302612, 9.813070696, 9.442952385, 9.752484376, 12.99750132, ...
X := [15.04570335, 10.95541035, 10.29295850, 9.077001231, 9.341020304, 9.269759934, 9.093358330, 10.43225069, 10.51313716, 9.889226946, 9.715302612, 9.813070696, 9.442952385, 9.752484376, 12.99750132, ...

10.33460490

1.577335327

The above are newly generated data. The following are those data in the text. We use the following at this time.

>    X := [11.9776, 9.3889, 9.9798, 13.4676, 9.2895, 10.1242, 9.5798, 9.3148, 9.0605, 9.1680, 11.0394, 9.1083, 10.3720, 9.0523, 13.2969, 10.5852];

X := [11.9776, 9.3889, 9.9798, 13.4676, 9.2895, 10.1242, 9.5798, 9.3148, 9.0605, 9.1680, 11.0394, 9.1083, 10.3720, 9.0523, 13.2969, 10.5852]
X := [11.9776, 9.3889, 9.9798, 13.4676, 9.2895, 10.1242, 9.5798, 9.3148, 9.0605, 9.1680, 11.0394, 9.1083, 10.3720, 9.0523, 13.2969, 10.5852]

>    xbar := Mean(X);
sx := StDev(X);

xbar := 10.30030000

sx := 1.454448762

>    probs := [seq(1/16, k = 1 .. 16)];
empPDF := zip((x,y)->(x,y),X,probs);

probs := [1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16]

empPDF := [11.9776, 1/16, 9.3889, 1/16, 9.9798, 1/16, 13.4676, 1/16, 9.2895, 1/16, 10.1242, 1/16, 9.5798, 1/16, 9.3148, 1/16, 9.0605, 1/16, 9.1680, 1/16, 11.0394, 1/16, 9.1083, 1/16, 10.3720, 1/16, 9.0...
empPDF := [11.9776, 1/16, 9.3889, 1/16, 9.9798, 1/16, 13.4676, 1/16, 9.2895, 1/16, 10.1242, 1/16, 9.5798, 1/16, 9.3148, 1/16, 9.0605, 1/16, 9.1680, 1/16, 11.0394, 1/16, 9.1083, 1/16, 10.3720, 1/16, 9.0...

>    for k from 1 to 1000 do
XX := DiscreteS(empPDF, 16):
TT[k] := (Mean(XX) - 10.3003)/(StDev(XX)/4):
od:
Tre := [seq(TT[k], k = 1 .. 1000)]:
tbar := Mean(Tre);
s := StDev(Tre);
Min(Tre), Max(Tre);

tbar := -.2511051556

s := 1.357579956

-9.543269484, 2.875516191

>    xtics := [seq(-6.5+0.5*k, k = 0 .. 20)]:
ytics := [seq(0.05*k, k = 1 .. 8)]:

>    P1 := HistogramFill(Tre, -6.5 .. 3.5, 20):
P2 := plot([[0,0],[0,0]], x=-6.5 .. 3.5, y = 0 .. 0.445, xtickmarks=xtics, ytickmarks=ytics, labels=[``,``]):
display({P1, P2});

`WARNING: There are`, 5, ` data points out of plot range.`

[Maple Plot]

Similar to Figure 5.4-3(a)

>    Treorder := sort(Tre):

>    ScatPlotPoint(Treorder, zper);

[Maple Plot]

Similar to Figure 5.4-3(b)

Now find the 0.025 and 0.975 quantiles

>    c := Percentile(Tre, 0.025);
d := Percentile(Tre, 0.975);

c := -3.933078026

d := 1.866063508

>    left := evalf(xbar - d*sx/4);

left := 9.621776560

>    right := evalf(xbar - c*sx/4);

right := 11.73041512

>    xbar;

10.30030000

>    sx;

1.454448762

Hopefully "10" is in the interval

>    [left, right];

[9.621776560, 11.73041512]

>   

Return to Menu