 V1

2023/05/16阅读：13主题：姹紫

# 统计学02: 二项分布

<~生~信~交~流~与~合~作~请~关~注~公~众~号@生信探索>

n 次伯努力事件(发生和不发生概率和为1)

using Distributionsd=Binomial(4, 0.35);mean(d) == 4*0.35var(d) == 4*0.35(1-0.35)

## Example

We asked various probability questions regarding the number of people out of 4 with blood type O+. We verified that the scenario was binomial and that each problem could be solved using the binomial formula. Instead of looking at it piecewise, we could describe the entire distribution of possible values and their corresponding probabilities. Since there are 4 people, there are several possible outcomes for the number who might have blood type O+: 0, 1, 2, 3, 4. We can make a distribution table with these outcomes. Recall that the probability of a randomly sampled person being blood type O+ is about 0.35.

pdf(distribution, x)计算分布密度（概率质量）函数在x处的值， 如果x是数组，结果返回数组； 如果x是数组且函数写成pdf!(distribution, x)，则结果保存在x中返回。 logpdf()计算其密度函数的自然对数值。

using CairoMakie,DistributionsCairoMakie.activate!()let    d=Binomial(4, 0.35);    x = 0:4    y = pdf.(d, x)    barplot(x, y)end

## Mississippi问题

mississippi字母有多少种排列组合方式。

using Combinatoricsmultiset_permutations("mississippi",11) |> length == 34650factorial(11)/(factorial(4)*factorial(4)*factorial(2)) == 34650.0

permutations("mississippi") |> length == 39916800

## Reference

https://www.bilibili.com/video/BV1CA411P7bL V1