New in Wolfram
Mathematica
8: Parameter Estimation and Testing
◄
previous
|
next
►
Core Algorithms
Compare Maximum-Likelihood and Cramér-von Mises Estimates
Visually compare parameter estimates for a normal distribution using maximum-likelihood estimation and optimizing the Cramér-von Mises test statistic.
In[1]:=
X
data = BlockRandom[SeedRandom[2]; RandomVariate[NormalDistribution[], 100]];
In[2]:=
X
cvmFit[\[Mu]_?NumericQ, \[Sigma]_?NumericQ, dist_] := CramerVonMisesTest[data, dist[\[Mu], \[Sigma]], "TestStatistic"]; cvmPar = Quiet[ FindMinimum[ cvmFit[\[Mu], \[Sigma], NormalDistribution], {{\[Mu]}, {\[Sigma]}}]]; mlePar = FindDistributionParameters[data, NormalDistribution[\[Mu], \[Sigma]]];
In[3]:=
X
Show[Plot3D[ cvmFit[\[Mu], \[Sigma], NormalDistribution], {\[Mu], -3, 3}, {\[Sigma], 0, 6}, ColorFunction -> ColorData["SouthwestColors"], PlotRange -> {{-2, 2}, {0, 3}, {-10, 35}}, MeshFunctions -> {#3 &}, MeshStyle -> Gray, Mesh -> 30, BoxRatios -> 1], Graphics3D[{Darker@Blue, Thickness[.01], Line[{{\[Mu], \[Sigma], 40}, {\[Mu], \[Sigma], -20}} /. cvmPar[[2]]]}], Graphics3D[{Darker@Red, Thickness[.01], Line[{{\[Mu], \[Sigma], 40}, {\[Mu], \[Sigma], -20}} /. mlePar]}]]
Out[3]=