Wolfram Language

Quantities in Probability & Statistics

Parameter Estimation from Quantity Data

Get the lengths of major rivers in North America in miles.

In[1]:=
Click for copyable input
data = Quantity[ExampleData[{"Statistics", "RiverLengths"}], "Miles"];
In[2]:=
Click for copyable input
h = Histogram[data, 30, PDF, Frame -> True, FrameLabel -> Automatic, PlotTheme -> "Detailed"]
Out[2]=

EstimatedDistribution accepts quantity data and returns QuantityDistribution with the units of the data.

In[3]:=
Click for copyable input
edist1 = EstimatedDistribution[data, InverseGammaDistribution[a, b, c, d]]
Out[3]=

Estimate model in different units.

In[4]:=
Click for copyable input
edist2 = EstimatedDistribution[data, QuantityDistribution[InverseGammaDistribution[a, b, c, d], "Kilometers"]]
Out[4]=

Convert the first model to kilometers.

In[5]:=
Click for copyable input
UnitConvert[edist1, "Kilometers"]
Out[5]=

Plot the data histogram together with the fitted model PDF.

In[6]:=
Click for copyable input
Show[h, Plot[PDF[edist1, Quantity[x, "Miles"]], {x, 0, 2000}]]
Out[6]=

Related Examples

de es fr ja ko pt-br ru zh