可视化带有加权球的瓮模型
一个瓮中含有10个权重为1的红球,15个权重为2的兰球. 独立地取出12个球,取出红色或蓝色球的概率取决于它的权重. 取出的红球数具有 FisherHypergeometricDistribution. 红/蓝图表代表这种情况的20次模拟.
𝒟 = Block[{m1 = 10, m2 = 15, n = 12, w1 = 1, w2 = 2}, FisherHypergeometricDistribution[n, m1, m1 + m2, w1 / w2]];sample = RandomVariate[𝒟, 20];DiscretePlot[PDF[𝒟, x], {x, 0, 12}, PlotStyle -> Hue[.4, .9, .6], BaseStyle -> {FontFamily -> "Verdana"}, PlotLabel -> 𝒟, ExtentSize -> 2 / 3, ImageSize -> 400, Epilog -> Inset[BarChart[Transpose[{sample, 12 - sample}], ChartLayout -> "Stacked", Ticks -> {False, True}, ChartStyle -> {Lighter[Red, 0.5], Lighter[Blue, 0.5]}, ImageSize -> 200], {Right, 0.3}, {Right, Top}]]