QuantityDistribution[dist,unit]
represents a distribution dist of quantities with unit specified by unit.
QuantityDistribution[dist,{unit1,unit2,…}]
represents a multivariate distribution with units {unit1,unit2,…}.
QuantityDistribution
QuantityDistribution[dist,unit]
represents a distribution dist of quantities with unit specified by unit.
QuantityDistribution[dist,{unit1,unit2,…}]
represents a multivariate distribution with units {unit1,unit2,…}.
Details
- QuantityDistribution is typically created by using quantities in parametric, derived distributions or estimated from data with quantities.
- QuantityDistribution will automatically attempt to parse an unknown unit string to its canonical form. »
- QuantityDistribution[dist,unit] is equivalent to TransformedDistribution[Quantity[x,unit],x dist]. »
- The arguments to distribution functions are assumed to have units compatible with unit. »
- The values of distribution functions for univariate distributions have the following units:
-
CDF unitless InverseCDF unit SurvivalFunction unitless InverseSurvivalFunction unit - The values of PDF and HazardFunction have the following units: »
-
continuous univariate dist unit-1 continuous multivariate dist unit1-1 unit2-1 … discrete dist unitless - Moments of univariate QuantityDistribution[dist,unit] have the following units:
-
Moment[…,r] unit r CentralMoment[…,r] unit r Cumulant[…,r] unit r FactorialMoment[…,r] unit r - Moments of multivariate QuantityDistribution[dist,unit] have the following units:
-
Moment[…,{r1,r2,…}] unit1r1 unit2r2 … CentralMoment[…,{r1,r2,…}] unit1r1 unit2r2 … Cumulant[…,{r1,r2,…}] unit1r1 unit2r2 … FactorialMoment[…,{r1,r2,…}] unit1r1 unit2r2 … - Moment-generating functions require their arguments to be quantities with units that are reciprocal to the units of the QuantityDistribution.
- Sampling from QuantityDistribution gives Quantity or QuantityArray.
- QuantityDistribution can be used with such functions as Mean, CDF, RandomVariate, QuantityMagnitude, and Expectation.
Examples
open all close allBasic Examples (3)
Define a distribution for a random position:
𝒟 = NormalDistribution[["120 cm"], ["16 cm"]]Compute the probability of the position exceeding a threshold:
Probability[x > ["1.5 yards"], x𝒟]Define a distribution of life expectancy:
𝒟 = GompertzMakehamDistribution[1 / ["9.9 yrs"], 2.5 10^-4, 393., 0]Compute conditional life expectancy:
NExpectation[tt > ["7 decades"], t𝒟]Fit a model to data with units:
times = Quantity[{2.35, 1.55, 2.7, 0.25, 1.5, 3.35, 1.85, 0.15, 2.3, 0.65, 0.85, 5.15}, "Minutes"];EstimatedDistribution[times, ExponentialDistribution[λ]]Convert the distribution to another compatible unit:
UnitConvert[%, "Hours"]Compare with fitting to distribution in hours:
EstimatedDistribution[times, QuantityDistribution[ExponentialDistribution[λ], "Hours"]]Scope (29)
Basic Uses (11)
Find the mean time of service for a device with WeibullDistribution-modeled lifetime:
𝒟 = WeibullDistribution[1.65, ["256.5 days"]]Mean[𝒟]Find the median time of service:
Median[𝒟]Compute the cumulative distribution function for a quantity distribution:
t𝒟 = QuantityDistribution[ExponentialDistribution[4.2], "Hours"];The argument of CDF is assumed to be a quantity of time:
cdf = CDF[t𝒟, t]Evaluate the cumulative distribution function for a few time values:
Table[cdf, {t, {["24 seconds"], ["12 minutes"], [".67 hours"]}}]//NFind the cumulative distribution function for the argument in minutes:
CDF[t𝒟, Quantity[t, "Minutes"]]Compute quantile of a QuantityDistribution:
𝒟 = QuantityDistribution[NormalDistribution[], "Meters"];Plot[Quantile[𝒟, q], {q, 0, 1}, AxesLabel -> Automatic]Quantile[𝒟, q]Sampling from QuantityDistribution gives Quantity or QuantityArray:
claimSize𝒟 = ParetoDistribution[["500 US Dollars"], 4]RandomVariate[claimSize𝒟]Sample 238 insurance claim sizes according to the chosen model:
data = RandomVariate[claimSize𝒟, 238]SmoothHistogram[data, AxesLabel -> Automatic, PlotRange -> All]Compute log-likelihood for distribution with quantities on data with quantities:
𝒟 = QuantityDistribution[ExponentialDistribution[6], "Day"];data = {Quantity[3.8, "Hours"], Quantity[MixedMagnitude[{1, 2}], MixedUnit[{"Days", "Hours"}]], Quantity[4.5, "Hours"], Quantity[3.2, "Hours"], Quantity[14, "Hours"], Quantity[MixedMagnitude[{15, 27}], MixedUnit[{"Hours", "Minutes"}]]};LogLikelihood[𝒟, data]Data can have any compatible units:
LogLikelihood[𝒟, UnitConvert[data, "Seconds"]]PDF for continuous distribution with quantities:
𝒟 = RayleighDistribution[["25 Watts"]]The probability density function has a reciprocal unit:
PDF[𝒟, Quantity[20., "Watts"]]This is consistent with substituting quantities into the symbolic expression for PDF:
Refine[PDF[RayleighDistribution[σ], x], x > 0]% /. {σ -> Quantity[25, "Watts"], x -> Quantity[20., "Watts"]}The PDF for discrete distribution with quantities is unitless:
𝒟 = QuantityDistribution[BinomialDistribution[n, p], IndependentUnit["Steps"]]PDF[𝒟, Quantity[k, IndependentUnit["Steps"]]]The HazardFunction for continuous distributions with quantities has reciprocal units:
𝒟 = GompertzMakehamDistribution[["5 per day"], 2.3]HazardFunction[𝒟, Quantity[t, "Weeks"]]Estimate the distribution of solar radiant energy reaching Earth's surface from synthetic data:
data = QuantityArray[{299.19, 208.21, 204.03, 207.03, 286.18, 274.87, 308.76, 330.78, 277.12, 310.37, 243.26, 187.98, 181.9, 341.17, 242.44, 303.59, 254.32, 166.39, 252.43, 258.81, 216.92, 179.36, 247.69, 326.41, 215.15, 237.08, 263.46, 222.36, 224.44, 278.86, 254.04, 184.58, 252.55, 201.28, 220.51, 213.77, 230.29, 187.74, 270.05, 304.37, 181.47, 241.86, 192.87, 289.77, 228.63, 254.84, 273.55, 251.85, 237.85, 196.00, 239.28, 200.45, 272.60, 260.15, 242.45, 262.57, 293.73, 269.73, 296.25, 352.47, 134.57, 337.09, 211.92, 321.31, 209.67, 171.45, 266.17, 288.09, 234.13, 222.63, 376.44, 251.15, 220.60, 239.87, 233.62, 199.96, 279.1, 207.18, 249.13, 180.77, 292.83, 139.66, 173.38, 214.88, 253.25, 211.03, 363.36, 189.20, 211.25, 255.80, 224.04, 164.23, 232.35, 183.27, 275.86, 212.63, 273.29, 148.21, 244.42, 316.37, 294.78, 284.16}, "Watts" / "Meters"^2]Subscript[𝒟, 1] = EstimatedDistribution[data, LogNormalDistribution[a, b]]Show[Histogram[data, Automatic, PDF], Plot[PDF[Subscript[𝒟, 1], Quantity[w, "Watts" / "Meters" ^ 2]]//Evaluate, {w, 120, 450}]]QuantityMagnitude and QuantityUnit of a quantity distribution:
𝒟 = NormalDistribution[["120 cm"], ["16 cm"]]Extract the distribution of the magnitude:
QuantityMagnitude[𝒟]QuantityUnit[𝒟]Use UnitConvert to convert distribution to compatible units:
UnitConvert[𝒟, "Millimeters"]Distribution of voltage with random resistance and current:
𝒟 = TransformedDistribution[𝓇 ℐ, {𝓇TriangularDistribution[{["0.9 Ohms"], ["1.2 Ohm"]}], ℐUniformDistribution[{["0.8 Amperes"], ["1.2 Amperes"]}]}]Use UnitSimplify to simplify units to "Volts":
UnitSimplify[𝒟]Construction (6)
Define distribution for a quantity of length:
QuantityDistribution[GammaDistribution[10, 5], "Centimeters"]Define the same distribution using a quantity scale parameter:
𝒟 = GammaDistribution[10, Quantity[5, "Centimeters"]]Median[𝒟]//NDefine joint distribution of height and weight:
QuantityDistribution[BinormalDistribution[{180, 92}, {12, 5}, 2 / 3], {"Centimeters", "Kilograms"}]Define the same distribution using quantity parameters:
BinormalDistribution[{["180 cm"], ["92 kg"]}, {["12 cm"], ["5 kg"]}, 2 / 3]Convert the distribution into different units:
UnitConvert[%, {"Meters", "Kilograms"}]Parsing of unknown unit strings is automatically attempted:
QuantityDistribution[UniformDistribution[{10, 20}], "Farengeit"]QuantityUnit[%]Quantities can be used to specify units in QuantityDistribution:
QuantityDistribution[StudentTDistribution[5], ["amperes"]]Magnitude of the input quantity is ignored:
QuantityDistribution[StudentTDistribution[5], ["10 amperes"]]Use TransformedDistribution to define distribution of random quantities:
TransformedDistribution[ Quantity[65, "mph"] Quantity[𝓉, "Minutes"], 𝓉TriangularDistribution[{90., 110.}]]Mean[%]Define data distribution with units:
ed = EmpiricalDistribution[RandomVariate[GumbelDistribution[1, .2], 10 ^ 3]];qd = QuantityDistribution[ed, "Meters"]Plot the cumulative distribution function:
Plot[CDF[qd, Quantity[x, "Meters"]]//Evaluate, {x, 0, 2}, AxesLabel -> Automatic]Estimation (4)
Estimate distribution from quantity data:
data = QuantityArray[RandomVariate[NormalDistribution[1, .5], 1000], "Meters"]Fit a normal distribution in meters to the data:
EstimatedDistribution[data, NormalDistribution[a, b]]Fit a normal distribution in feet to the data:
EstimatedDistribution[data, QuantityDistribution[NormalDistribution[a, b], "Feet"]]Estimate parameters of a multivariate distribution:
data = RandomVariate[QuantityDistribution[MultivariateTDistribution[{{.6, .7}, {.7, 1}}, 10], {"Meters", "Yards"}], 500]Fit a multivariate
distribution in the units of the data:
EstimatedDistribution[data, MultivariateTDistribution[Array[s, {2, 2}], n]]Fit a multivariate
distribution in compatible units:
EstimatedDistribution[data, QuantityDistribution[MultivariateTDistribution[Array[s, {2, 2}], n], "Meters"]]Estimate distribution from the quantity data:
data = QuantityArray[ExampleData[{"Statistics", "OldFaithful"}], {"Seconds", "Minutes"}]The data is bimodal, suggesting a mixture of bivariate normal distributions might be a good fit:
SmoothHistogram3D[data, AxesLabel -> Automatic]dist = MixtureDistribution[{p1, p2}, {BinormalDistribution[{m1, m2}, {s1, s2}, r1], BinormalDistribution[{m3, m4}, {s3, s4}, r2]}];EstimatedDistribution gives QuantityDistribution with fitted parameters:
EstimatedDistribution[data, dist]FindDistributionParameters gives rules with Quantity values when possible:
FindDistributionParameters[data, dist]Substituting these parameters into the model results in QuantityDistribution:
dist /. %Estimate distribution from quantity data:
data = QuantityArray[RandomVariate[GammaDistribution[2, 3], 1000], "Meters"]Specify starting values of relevant parameters using quantities:
EstimatedDistribution[data, GammaDistribution[a, b], {{a, 2}, {b, ["3 yrds"]}}]Parameters of magnitude distribution dist in QuantityDistribution[dist,units] are numeric:
EstimatedDistribution[data, QuantityDistribution[GammaDistribution[a, b], "Meters"], {{a, 2}, {b, 3}}]Derived Distributions (8)
Truncate a quantity distribution:
q𝒟 = QuantityDistribution[NormalDistribution[0, 1], "Meters"];Truncation of QuantityDistribution gives another QuantityDistribution:
TruncatedDistribution[{["0 m"], ["3 m"]}, q𝒟]Censor a quantity distribution:
q𝒟 = QuantityDistribution[NormalDistribution[0, 1], "Meters"];Censoring of QuantityDistribution gives another QuantityDistribution:
cq𝒟 = CensoredDistribution[{["0 m"], Infinity}, q𝒟]Compute the mean of the censored quantity distribution:
Mean[cq𝒟]//NDefine mixture of quantity distributions:
qd1 = QuantityDistribution[NormalDistribution[-2, 1], "Meters"];
qd2 = QuantityDistribution[NormalDistribution[2, 1], "Meters"];Mixture of compatible QuantityDistributions gives another QuantityDistribution:
MixtureDistribution[{1 / 2, 1 / 2}, {qd1, qd2}]Define a spliced distribution with quantity distributions:
qd1 = QuantityDistribution[ExponentialDistribution[.2], "Meters"];
qd2 = QuantityDistribution[ExponentialDistribution[3], "Meters"];Splicing several QuantityDistributions gives another QuantityDistribution:
SplicedDistribution[{2, 1}, {Quantity[0, "Meters"], Quantity[4, "Meters"], Infinity}, {qd1, qd2}]Sample from the spliced distribution and visualize the histogram:
Histogram[RandomVariate[%, 10 ^ 3], 30, "PDF"]ProductDistribution of quantity distributions:
qd1 = NormalDistribution[Quantity[0, "Meters"], Quantity[1, "Meters"]];
qd2 = QuantityDistribution[BinormalDistribution[.2], "Seconds"];Product distribution evaluates to QuantityDistribution:
ProductDistribution[{qd1, 3}, qd2]Moment[%, {2, 2, 2, 2, 2}]Create a parameter mixture with quantity distribution:
qd = QuantityDistribution[ExponentialDistribution[λ], "Seconds"];Parameter mixture of QuantityDistribution evaluates to QuantityDistribution:
ParameterMixtureDistribution[qd, λExponentialDistribution[3]]Define distribution of the maximum of random quantities:
qd1 = QuantityDistribution[GammaDistribution[2, 3], "Meters"];
qd2 = QuantityDistribution[GammaDistribution[1, 2], "Yards"];The distribution of the order statistics gives QuantityDistribution:
𝒟 = OrderDistribution[{qd1, qd2}, 2]Plot[PDF[𝒟, Quantity[x, "Yards"]]//Evaluate, {x, 0, 40}, AxesLabel -> Automatic]QuantityDistribution of a QuantityDistribution:
QuantityDistribution[QuantityDistribution[LogNormalDistribution[1.3, .4], "Kilograms"], "Pounds"]The result is consistent with the behavior of Quantity under composition:
TransformedDistribution[Quantity[Quantity[x, "Kilograms"], "Pounds"], xLogNormalDistribution[1.3, .4]]QuantityDistribution[EmpiricalDistribution[QuantityArray[RandomReal[1, 10], "Seconds"]], "Minutes"]QuantityUnit[%]Applications (8)
The average speed of cars traveling from Champaign, Illinois, to Chicago, Illinois, is well described as a triangular random variable:
speed𝒟 = TriangularDistribution[{["55 mi/h"], ["82 mph"]}, ["72 mph"]]Find the expected time of travel:
Expectation[GeoDistance[["Champaign, IL"], ["Chicago, IL"]] / v, vspeed𝒟]UnitConvert[%, MixedUnit[{"Hours", "Minutes"}]]Define the distribution of a cube's side-length measurements:
ℓ𝒟 = BatesDistribution[3, {["23.5 cm"], ["24.3 cm"]}]Plot the distribution density:
Plot[PDF[ℓ𝒟, Quantity[s, "Centimeters"]]//Evaluate, {s, 23.2, 24.5}, Exclusions -> None]Compute the mean and the dispersion measures of the cube's volume:
Mean[TransformedDistribution[s ^ 3, sℓ𝒟]]StandardDeviation[TransformedDistribution[s ^ 3, sℓ𝒟]]Plot the PDF of the cube's volume:
Plot[PDF[TransformedDistribution[s ^ 3, sℓ𝒟], Quantity[vol, "Liters"]]//Evaluate, {vol, 12, 15}, Exclusions -> None, AxesLabel -> {"Liters", None}]Recorded body weights in kilograms:
data = QuantityArray[{67, 69, 57, 78, 89, 65, 57, 80, 73, 66, 61, 70, 64, 74, 77, 69, 76, 71, 75, 93, 77, 78, 72, 80, 63, 78, 78, 52, 80, 47, 70, 76, 63, 77, 69, 68, 48, 71, 71, 69, 68, 79, 67, 75, 56, 62, 81, 92, 63, 74, 72, 90, 58, 47, 58, 63, 62, 73, 70, 85, 61, 75, 53, 59, 63, 76, 78, 67, 67, 83, 61, 62, 75, 68, 82, 65, 84, 71, 49, 70, 60, 72, 61, 63, 84, 69, 69, 52, 56, 81, 78, 72, 59, 67, 75, 52, 67, 65, 68, 60}, "Kilograms"];Plot the histogram of the data:
h = Histogram[data, Automatic, "PDF", AxesLabel -> Automatic]Fit NormalDistribution to the data:
edist = EstimatedDistribution[data, NormalDistribution[a, b]]Compare the histogram with the estimated PDF:
Show[h, Plot[Evaluate[PDF[edist, Quantity[x, "Kilograms"]]], {x, 20, 120}]]Express the estimated distribution in pounds:
UnitConvert[edist, "Pounds"]DistributionFitTest[data, NormalDistribution[m, s], "TestConclusion"]The waiting time a customer spends in a restaurant is believed to be exponentially distributed with an average wait time of 5 minutes:
{sol} = Solve[Mean[ExponentialDistribution[λ]] == Quantity[5, "Minutes"], λ]𝒟 = ExponentialDistribution[λ /. sol]Find the probability that the customer will have to wait more than 10 minutes:
NProbability[t > Quantity[10, "Minutes"], t𝒟]The lifetime of a component has WeibullDistribution with shape and scale parameters of 2 and 997.5 hours, respectively. Find the probability that the component survives 300 hours:
𝒟 = WeibullDistribution[2, Quantity[997.5, "Hours"]]Probability[x ≥ Quantity[300, "Hours"], x𝒟]Find the probability that the component is still working after 500 hours, given that it has survived 300 hours:
NProbability[x ≥ Quantity[500, "Hours"]x ≥ Quantity[300, "Hours"], x𝒟]Find the mean time to failure:
Mean[𝒟]Estimate the distribution of the daily mean temperature in Chicago in the summer of 2015:
tempsChicago = WeatherData["Chicago", "MeanTemperature", {{2015, 5, 15}, {2015, 9, 15}, "Day"}]hist = Histogram[tempsChicago, Automatic, PDF]Fit the distribution to PERTDistribution:
dist = EstimatedDistribution[tempsChicago, PERTDistribution[{min, max}, med, λ]]Show[hist, Plot[PDF[dist, Quantity[t, "Celsius"]]//Evaluate, {t, -7, 32}]]Find the estimated distribution for temperature in degrees Fahrenheit:
UnitConvert[dist, "DegreesFahrenheit"]Velocity density function along any direction of a gas molecule follows a normal distribution with mean 0 and standard deviation
. The standard deviation for molecular hydrogen at 573 K is:
σv = Block[{k = Quantity["BoltzmannConstant"], T = Quantity[573, "Kelvins"], m = ChemicalData["Hydrogen", "MolecularMass"]}, Sqrt[k T / m]]//UnitConvertThe distribution of the speeds of molecules in a hydrogen gas at 573 K is given:
𝒟 = MaxwellDistribution[σv]PDF[𝒟, Quantity[v, "Meters" / "Seconds"]]Plot[PDF[𝒟, Quantity[v, "Meters" / "Seconds"]]//Evaluate, {v, 0, 6000}, Filling -> Axis]Find the probability that a hydrogen molecule has speed at least 4000 meters per second:
Probability[x ≥ Quantity[4000, "Meters" / "Seconds"], x𝒟]Find the average speed of such a molecule:
Mean[𝒟]Compare the ratios of the average speed and the RMS speed to the most probable speed:
vMP = Quantity[x, "Meters" / "Seconds"] /. x -> First[FindArgMax[PDF[𝒟, Quantity[x, "Meters" / "Seconds"]], {x, 2100}]]{Mean[𝒟] / vMP, Sqrt[Moment[𝒟, 2]] / vMP}Simulate the speed of 100 hydrogen molecules in the above conditions:
ListPlot[{RandomVariate[𝒟, 100], {{0, Mean[𝒟]}, {100, Mean[𝒟]}}}, Joined -> {False, True}, Filling -> Axis, AxesLabel -> Automatic]The acceleration of gravity can be measured by measuring a pendulum's period
and its length
using
. The uncertainty in the average of five repeated measurements of the period is modeled with a BatesDistribution:
μT = Quantity[2, "Seconds"];ΔT = Quantity[0.01, "Seconds"];
period𝒟 = BatesDistribution[5, {μT - ΔT / 2, μT + ΔT / 2}]The pendulum's length has been measured using a ruler with resolution of 1 mm, so its uncertainty is modeled with a UniformDistribution:
μlen = Quantity[1, "Meters"];Δlen = UnitConvert[Quantity[1, "mm"], "Meters"];
len𝒟 = UniformDistribution[{μlen - Δlen / 2., μlen + Δlen / 2.}]The uncertainty in the measurement of the acceleration of gravity:
g𝒟 = TransformedDistribution[ (2 π)^2len / T^2, {lenlen𝒟, Tperiod𝒟}]Compare to the linear approximation:
lin[e_, {x_, x0_}, {y_, y0_}] := Block[{f = Function@@{{x, y}, e}}, f[x0, y0] + f^(1, 0)[x0, y0](x - x0) + f^(0, 1)[x0, y0](y - y0)]lin𝒟[𝒟_] := NormalDistribution[Mean[𝒟], StandardDeviation[𝒟]]gApprox𝒟 = TransformedDistribution[lin[(2Pi) ^ 2len / T ^ 2, {len, μlen}, {T, μT}], {lenlin𝒟[len𝒟], Tlin𝒟[period𝒟]}]Compute the average acceleration using the exact and the linearized distributions:
{μg, μgApprox} = {NExpectation[g, gg𝒟], NExpectation[g, ggApprox𝒟]}Compute the scales of uncertainty:
{σg, σgApprox} = {Sqrt[NExpectation[(g - μg) ^ 2, gg𝒟]], StandardDeviation[gApprox𝒟]}Find the sampling estimate of the 90% confidence interval for the measured acceleration:
confidenceInterval = Quantile[RandomVariate[g𝒟, 10 ^ 6], {0.05, 0.95}]NProbability[First[confidenceInterval] < x < Last[confidenceInterval], xg𝒟]Properties & Relations (6)
QuantityDistribution with dimensionless units will auto-evaluate to the magnitude distribution:
QuantityDistribution[GammaDistribution[2, 3], "DimensionlessUnit"]QuantityDistribution[GammaDistribution[2, 3], "Meters" / "Meters"]Use QuantityMagnitude and QuantityUnit to extract distribution and units:
qdist = NormalDistribution[["120 cm"], ["16 cm"]]{QuantityMagnitude[qdist], QuantityUnit[qdist]}QuantityDistribution[dist,unit] is equivalent to TransformedDistribution:
TransformedDistribution[Quantity[x, "Grams"], xNormalDistribution[μ, σ]]Skewness and kurtosis of a QuantityDistribution are unitless:
𝒟 = QuantityDistribution[GumbelDistribution[20, 3], "Joules"];Skewness[𝒟]Kurtosis[𝒟]Joint distribution of mass and acceleration:
𝒟 = QuantityDistribution[BinormalDistribution[{200, 9.81}, {5, 0.01}, 1 / 2], {"Grams", "Meters" / "Seconds" ^ 2}];The unit of the moment of order (1,1) is the product of units of each component:
Moment[𝒟, {1, 1}]The moment can be interpreted as the expected value of force:
UnitSimplify[%]PDF of a continuous distribution with units integrates to 1 over its domain:
𝒟 = CauchyDistribution[["120 cm"], ["16 cm"]]pdf = PDF[𝒟, Quantity[x, "Meters"]]Reciprocal units of the density function are canceled by the unit of the measure to give unitless antiderivative:
Integrate[pdf, Quantity[x, "Meters"]]Total probability is equal to 1:
Integrate[pdf, {Quantity[x, "Meters"], ["-∞ meter"], ["+∞ meters"]}]Possible Issues (4)
The dimensionality of the distribution and units must agree:
𝒟 = QuantityDistribution[BinormalDistribution[r], {"Meters", "Pounds", "Watts"}];
DistributionParameterQ[𝒟]Specify two units for two dimensions:
𝒟 = QuantityDistribution[BinormalDistribution[r], {"Meters", "Pounds"}];
Mean[𝒟]The identical unit for all dimensions:
𝒟 = QuantityDistribution[BinormalDistribution[r], "Volts"];
Mean[𝒟]The unit conversion may map the data outside of the support of the distribution:
data = QuantityArray[RandomVariate[MultinomialDistribution[15, {.3, .7}], 100], {"Grams", "Pounds"}];Estimate a quantity distribution in kilograms:
EstimatedDistribution[data, QuantityDistribution[MultinomialDistribution[n, {p, q}], "Kilograms"]]Estimate using the units of the data:
EstimatedDistribution[data, MultinomialDistribution[n, {p, q}]]Then convert the distribution:
UnitConvert[%, "Kilograms"]Setting fixed values for parameter estimation is unit dependent:
data = QuantityArray[RandomReal[{-1, 1}, 10 ^ 2], "DegreesCelsius"]distC = EstimatedDistribution[data, NormalDistribution[0, s]]distF = EstimatedDistribution[UnitConvert[data, "DegreesFahrenheit"], NormalDistribution[0, s]]{StandardDeviation[distC], UnitConvert[StandardDeviation[distF], "DegreesCelsius"]}{QuantityMagnitude[Quantity[0, "DegreesCelsius"]], QuantityMagnitude[Quantity[0, "DegreesFahrenheit"], "DegreesCelsius"]}Convert the whole quantity distribution instead:
UnitConvert[distF, "DegreesCelsius"]Use converted units in call to estimation:
distF2 = EstimatedDistribution[UnitConvert[data, "DegreesFahrenheit"], NormalDistribution[QuantityMagnitude[Quantity[0, "DegreesCelsius"], "DegreesFahrenheit"], s]]UnitConvert[distF2, "DegreesCelsius"]% == distCThe magnitude of the factorial moment of a QuantityDistribution coincides with the factorial moment of the magnitude distribution:
𝒟 = QuantityDistribution[NormalDistribution[μ, σ], "Meters"]FactorialMoment[𝒟, 2]FactorialMoment[NormalDistribution[μ, σ], 2]Factorial moment expression is not homogeneous in the location and scale parameters, hence direct substitution of quantity parameters results in an error:
% /. {μ -> Quantity[μ, "Meters"], σ -> Quantity[σ, "Meters"]}Related Guides
History
Text
Wolfram Research (2016), QuantityDistribution, Wolfram Language function, https://reference.wolfram.com/language/ref/QuantityDistribution.html.
CMS
Wolfram Language. 2016. "QuantityDistribution." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/QuantityDistribution.html.
APA
Wolfram Language. (2016). QuantityDistribution. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/QuantityDistribution.html
BibTeX
@misc{reference.wolfram_2026_quantitydistribution, author="Wolfram Research", title="{QuantityDistribution}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/QuantityDistribution.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_quantitydistribution, organization={Wolfram Research}, title={QuantityDistribution}, year={2016}, url={https://reference.wolfram.com/language/ref/QuantityDistribution.html}, note=[Accessed: 12-June-2026]}