New in Wolfram
Mathematica
8: Nonparametric, Derived, and Formula Distributions
◄
previous
|
next
►
Core Algorithms
Truncate a Distribution
The PDF of
TruncatedDistribution
is more peaked and is nonzero on a smaller domain when compared with the original distribution.
In[1]:=
X
LeftTruncated\[ScriptCapitalD] = TruncatedDistribution[{-1, \[Infinity]}, NormalDistribution[]]; RightTruncated\[ScriptCapitalD] = TruncatedDistribution[{-\[Infinity], 1}, NormalDistribution[]]; DoubleTruncated\[ScriptCapitalD] = TruncatedDistribution[{-1, 1}, NormalDistribution[]]; g1 = Table[Plot[{PDF[m, x], PDF[NormalDistribution[], x]}, {x, -3, 3}, Filling -> Axis, Exclusions -> None], {m, {LeftTruncated\[ScriptCapitalD], RightTruncated\[ScriptCapitalD], DoubleTruncated\[ScriptCapitalD]}}];
In[2]:=
X
\[ScriptCapitalD] = ProductDistribution[NormalDistribution[], LaplaceDistribution[-1/2, 1]]; \[ScriptCapitalT]1 = TruncatedDistribution[{{-\[Infinity], 1}, {-\[Infinity], \[Infinity]}}, \[ScriptCapitalD]]; \ \[ScriptCapitalT]2 = TruncatedDistribution[{{-\[Infinity], \[Infinity]}, {-\[Infinity], 1}}, \[ScriptCapitalD]]; \[ScriptCapitalT]3 = TruncatedDistribution[{{-\[Infinity], 1}, {-\[Infinity], 1}}, \[ScriptCapitalD]]; g2 = Table[Plot3D[ Evaluate[{PDF[\[ScriptCapitalD], {x, y}], PDF[m, {x, y}]}], {x, -2, 2}, {y, -2, 2}, PlotStyle -> {Lighter@ColorData[1, 1], Directive[Lighter@ColorData[1, 2], Opacity[0.7]]}, PlotRange -> All, Lighting -> "Neutral", ExclusionsStyle -> Directive[Yellow, Opacity[0.5]], Mesh -> None, AxesLabel -> Automatic], {m, {\[ScriptCapitalT]1, \[ScriptCapitalT]1, \ \[ScriptCapitalT]3}}];
In[3]:=
X
Framed[GraphicsGrid[{g1, g2}, ImageSize -> 550, Spacings -> {Automatic, 150}], RoundingRadius -> 10, FrameStyle -> GrayLevel@0.3, FrameMargins -> 10, Background -> LightYellow]
Out[3]=