New in Wolfram
Mathematica
8: Probability and Statistics Solvers and Properties
◄
previous
|
next
►
Core Algorithms
Compare Two Distributions with the Same Moment Sequence
Use varying scales to see fine-grained detail and general shapes of PDFs for two different distributions with equivalent moments, and compare their first several moments in tables.
In[1]:=
X
dist1 = ProbabilityDistribution[ 1/4 Exp[-Abs[x]^(1/2)], {x, -Infinity, Infinity}]; dist2 = ProbabilityDistribution[ 1/4 Exp[-Abs[x]^(1/2)] (1 + Cos[Sqrt[Abs[x]]]), {x, -Infinity, Infinity}]; momentTable[dist_, kmax_, name_, color_] := Grid[Join[{{Style[name, Bold, FontSize -> 14, FontFamily -> "Verdana"], SpanFromLeft}, {Style["Order", Italic, FontFamily -> "Verdana"], Style["Value", Italic, FontFamily -> "Verdana"]}}, Table[{Style[k, FontFamily -> "Verdana"], Style[Moment[dist, k], FontFamily -> "Verdana"]}, {k, kmax}]], Alignment -> {Left, Center}, Background -> {None, {{color, GrayLevel[.9]}}}, FrameStyle -> Directive[Thick, White], Dividers -> {All, {White, {True}, White}}]; fgrid = Grid[{{TraditionalForm[ Moment[r] == HoldForm[(1 + (-1)^r)/2 (2 r + 1)!]]}}, Alignment -> {Left, Center}, Background -> {None, {{Hue[.6, .15, .9], GrayLevel[.9]}}}, FrameStyle -> Directive[Thick, White], BaseStyle -> {Bold, FontSize -> 14, FontFamily -> "Verdana"}, Dividers -> {All, {White, {True}, White}}]; Row[{GraphicsColumn[ Table[LogPlot[{PDF[dist1, x], PDF[dist2, x]}, {x, -10^k, 10^k}, PlotRange -> All, Filling -> Axis], {k, 2, 4}], ImageSize -> 300], Column[{fgrid, momentTable[dist1, 10, TraditionalForm[Subscript[f, 1][x] == PDF[dist1, x]], Lighter[ColorData[1][1], .6]], momentTable[dist2, 10, TraditionalForm[Subscript[f, 2][x] == PDF[dist2, x]], Lighter[ColorData[1][2], .6]]}, Spacings -> 2]}]
Out[1]=