Wolfram Language™

Normalization of Formula Distributions

Use ProbabilityDistribution with option Method->"Normalize" to automatically compute the normalization coefficient.

In[1]:=
```uv\[ScriptCapitalD] = ProbabilityDistribution[Sin[x] Exp[-x], {x, 0, Pi}, Method -> "Normalize"]```
Out[1]=

Sample from the distribution and compare the histogram with the density function.

show complete Wolfram Language input
In[2]:=
```Show[Histogram[RandomVariate[uv\[ScriptCapitalD], 10^4], Automatic, PDF, PlotTheme -> "Detailed"], Plot[PDF[uv\[ScriptCapitalD], x], {x, 0, Pi}, PlotTheme -> "Marketing"], ImageSize -> Medium]```
Out[2]=

Normalize a multivariate distribution with option Method->"Normalize".

In[3]:=
```mv\[ScriptCapitalD] = ProbabilityDistribution[Boole[x^2 + y^2 < 1], {x, 0, 1}, {y, 0, 1}, Method -> "Normalize"]```
Out[3]=
show complete Wolfram Language input
In[4]:=
```Show[Histogram3D[ RandomVariate[mv\[ScriptCapitalD], 10^4, Method -> "AcceptanceRejection"], 10, PDF, PlotTheme -> "Detailed"], Plot3D[PDF[mv\[ScriptCapitalD], {x, y}], {x, 0, 1}, {y, 0, 1}, PlotStyle -> None], ImageSize -> Medium]```
Out[4]=