New in Wolfram
Mathematica
8: Parametric Probability Distributions
◄
previous
|
next
►
Core Algorithms
Analyze Card Games with Hypergeometric Distribution
Use
HypergeometricDistribution
[5, 13, 52]
for five-card poker and
HypergeometricDistribution
[13, 13, 52]
for bridge.
In[1]:=
X
fgrid[list_, {col1_, col2_}] := TraditionalForm@ Grid[list, Dividers -> All, Spacings -> {{1, 1}, 2}, Alignment -> {Left, Center, {{1, 1} -> {Center}, {1, 2} -> {Center}}}, BaseStyle -> {FontFamily -> "Verdana"}, Background -> {None, {Lighter[ Blend[{col1, col2}], .4], {Lighter[Blend[{col1, col2}], .7], GrayLevel[.9]}}}, FrameStyle -> Directive[Thick, White]]
In[2]:=
X
dPlot[dist_, dom_, range_, label_] := DiscretePlot[PDF[dist, k], dom, ExtentSize -> 2/3, PlotRange -> range, AxesOrigin -> {-0.2, 0}, BaseStyle -> {FontFamily -> "Verdana"}, Frame -> {{True, False}, {True, False}}, FrameLabel -> {Style["number of spades", Bold, 12], None}, ImageSize -> 280, PlotLabel -> Framed[Style[Grid[{{label}, {dist}}], 12], RoundingRadius -> 5, Background -> LightOrange]]
In[3]:=
X
Grid[{{fgrid[ Join[{{" " , "Probability of"}}, Table[{Row[{"at least ", k, " spades"}], NProbability[x >= k, x \[Distributed] HypergeometricDistribution[5, 13, 52]]}, {k, 1, 5}]], {Red, Red}], " ", dPlot[HypergeometricDistribution[5, 13, 52], {k, 0, 5}, {0, 0.45}, "Five-card poker"]}, {""}, {" "}, {fgrid[ Join[{{" " , "Probability of"}}, Table[{Row[{"at least ", k, " spades"}], NProbability[x >= k, x \[Distributed] HypergeometricDistribution[13, 13, 52]]}, {k, 1, 13}]], {Blue, Green}], " ", dPlot[HypergeometricDistribution[13, 13, 52], {k, 0, 13}, {0, 0.3}, "Bridge"]}}]
Out[3]=