(*^
::[ Information =
"This is a Mathematica Notebook file. It contains ASCII text, and can be
transferred by email, ftp, or other text-file transfer utility. It should
be read or edited using a copy of Mathematica or MathReader. If you
received this as email, use your mail application or copy/paste to save
everything from the line containing (*^ down to the line containing ^*)
into a plain text file. On some systems you may have to give the file a
name ending with ".ma" to allow Mathematica to recognize it as a Notebook.
The line below identifies what version of Mathematica created this file,
but it can be opened using any other version as well.";
FrontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.2";
MacintoshStandardFontEncoding;
fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e8, 24, "Times";
fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e6, 18, "Times";
fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, e6, 14, "Times";
fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, a20, 18, "Times";
fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, a15, 14, "Times";
fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, a12, 12, "Times";
fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times";
fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L-5, 12, "Courier";
fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier";
fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R65535, L-5, 12, "Courier";
fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier";
fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, B65535, L-5, 12, "Courier";
fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, 12, "Courier";
fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, 10, "Geneva";
fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = leftheader, inactive, L2, 12, "Times";
fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7, 12, "Times";
fontset = leftfooter, inactive, L2, 12, "Times";
fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times";
fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
paletteColors = 128; automaticGrouping; currentKernel;
]
:[font = input; preserveAspect]
ClearAll;Clear[f];Clear[s];Clear[Q];
$DefaultFont = {"Times-Roman",10};
Needs["Statistics`DataManipulation`"];
Needs["Graphics`Graphics`"];
ratpupilradii = {0.25,0.25,0.375,0.375,0.375,0.375,0.5,0.5,0.5, 0.5,0.5,
0.5, 0.5, 0.75, 0.75, 0.75, 1.0, 1.0,1.0,1.25,1.5,1.75};
xcum = {0.1875,0.3125,0.4375,0.5625,0.8125,1.0625,1.3125,1.5625,1.8125};
ycum = {0,2,6,13,16,19,20,21,22}/22;
datapoints = Table[{xcum[[i]],ycum[[i]]},{i,1,9}];
datapoints2 = Table[{Pi xcum[[i]]^2,ycum[[i]]},{i,1,9}];
smle = Sqrt[7/11];
Q[s_]:= 22 Log[2] - 44 Log[s] + Apply[Plus,Log[ratpupilradii]] -
Apply[Plus,ratpupilradii^2]/s^2;
plotllf = Plot[Q[s],{s,0.5,1},
PlotRange->{{0.66,1},{-10,-8}},
AxesLabel->{"s","Q"},
AxesOrigin->{0.65,-10.05},
AspectRatio->2/GoldenRatio,
PlotLabel->"(a) Loglikelihood function"];
F[n_,s_,x_]:= 1 - E^(-(x/s)^n);
f[n_,s_,x_]:= (n(x/s)^(n-1) E^(-(x/s)^n))/s;
error[s_] = Apply[Plus,Table[(F[2,s,xcum[[k]]]-ycum[[k]])^2,{k,1,9}]];
leasterror = FindMinimum[error[s],{s,0.67,0.5,1}];
Plot[error[s],{s,0.5,1}];
sopt = s/.leasterror[[2]]
Print["Error is ",leasterror[[1]]];
fmle[x_]:= (2 x/(smle^2)) E^(-(x/smle)^2);
FMLE[x_]:= 1 - E^(-(x/smle)^2);
plotfmle = Plot[fmle[x],{x,0,2}];
plotFMLE = Plot[FMLE[x],{x,0,2}];
up:= Show[Plot[f[2,sopt,x],{x,0,2},
PlotRange->{{0,2.05},Automatic},PlotStyle->Dashing[{0.001,0.01}],
Axes->True,AxesOrigin->{-0.03,-0.04},
PlotLabel->"(b) p.d.f.",
AxesLabel->{" x","f"}],plotfmle];
down:= Show[Plot[F[2,sopt,x],{x,0,2},
PlotRange->{{0,2.05},{0,1.05}},PlotStyle->Dashing[{0.001,0.01}],
Axes->True,AxesOrigin->{-0.03,-0.03},
PlotLabel->"(c) c.d.f.",
AxesLabel->{" x","F"}],plotFMLE,
ListPlot[datapoints]];
Show[GraphicsArray[{plotllf,GraphicsArray[{{up},{down}}]}],
PlotLabel->" Figure 31.3\n
Distribution of pupil radius in rats (population solid, sample dashed)"]
^*)