« View all new features in
Mathematica
9
◄
previous
|
next
►
New in
Mathematica
9
›
Enhanced Probability & Statistics
Define a Distribution Given Its Hazard Function
A hazard function is given.
In[1]:=
X
h[x_] := Piecewise[{{1, x < 1}, {Exp[-x], x >= 1}}]
Define a
ProbabilityDistribution
using the hazard function.
In[2]:=
X
\[ScriptCapitalD] = ProbabilityDistribution[{"HF", h[x]}, {x, 0, \[Infinity]}]
Out[2]=
Plot distribution functions.
In[3]:=
X
GraphicsGrid[ Partition[ Table[Plot[fun[\[ScriptCapitalD], x], {x, 0, 4}, Filling -> Axis, PlotLabel -> fun, ImageSize -> 200], {fun, {PDF, CDF, HazardFunction, SurvivalFunction}}], 2, 2]]
Out[3]=
Simulate and plot the histogram.
In[4]:=
X
data = RandomVariate[\[ScriptCapitalD], 10^5]; Histogram[data, {0, 6, .1}, "PDF", ImageSize -> 300]
Out[4]=