Wolfram 语言

概率和统计延伸

公式分布的归一化

使用 ProbabilityDistribution 以及选项 Method->"Normalize" 自动计算归一化系数.

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

从分布取样,并比较直方图和密度函数.

显示完整的 Wolfram 语言输入
In[2]:=
Click for copyable input
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]=

用选项 Method->"Normalize" 归一化多元正态分布.

In[3]:=
Click for copyable input
mv\[ScriptCapitalD] = ProbabilityDistribution[Boole[x^2 + y^2 < 1], {x, 0, 1}, {y, 0, 1}, Method -> "Normalize"]
Out[3]=
显示完整的 Wolfram 语言输入
In[4]:=
Click for copyable input
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]=

相关范例

de en es fr ja ko pt-br ru