New in Wolfram
Mathematica
8: Parameter Estimation and Testing
◄
previous
|
next
►
Core Algorithms
Visualize Optimal Parameter Values
Fit data to a Weibull distribution using maximum likelihood and visualize the optimal point in contour and 3D plots of the log-likelihood.
In[1]:=
X
data = BlockRandom[SeedRandom[100]; RandomVariate[WeibullDistribution[4, 5], 50]];
In[2]:=
X
params = FindDistributionParameters[data, WeibullDistribution[\[Alpha], \[Beta]]];
In[3]:=
X
llfun = LogLikelihood[WeibullDistribution[\[Alpha], \[Beta]], data]; cp = Show[ ContourPlot[llfun, {\[Alpha], 2, 6}, {\[Beta], 3, 8}, Contours -> 20, ColorFunction -> "FallColors"], Graphics[Point[{\[Alpha], \[Beta]} /. params]]]; p3d = Show[ Plot3D[llfun, {\[Alpha], 2, 6}, {\[Beta], 3, 8}, MeshFunctions -> {#3 &}, Mesh -> 20, PlotPoints -> 50, ColorFunction -> "FallColors"], Graphics3D[{Black, Sphere[{\[Alpha], \[Beta], llfun} /. params, .05]}]]; GraphicsRow[{cp, p3d}]
Out[3]=