模擬投擲三枚硬幣
Author: 藍邦偉　老師

$ 三反面 $

$ 投擲三枚硬幣 $

$ 一正兩反 $

$ 兩正一反 $

$ 三正面 $

$ 次 $
$數$

k = 0 (slider from 0 to n, step 1)
a = 1 (slider from 0 to 1, step 0.01)
n = 0 (slider from 0 to 2000, step 1)
list3 = Sequence(Random[0, 1] + a * 0, i, 1, n)
list2 = Sequence(Random[0, 1] + a * 0, i, 1, n)
list1 = Sequence(Random[0, 1] + a * 0, i, 1, n)
listA = Sequence(Element[list1, i] + Element[list2, i] + Element[list3, i], i, 1, Min[k, n])
listB = Sequence(CountIf[x ≟ i, listA], i, 0, 3)
m: floor(Max[listB] / 20) + 1
d = Segment((0, 0), (0, 20))
c_1 = Segment((0.0675, -0.135), (40.0675, -0.135))
A = (-0.21143007500000824, 21.89282207500002)
listC = Sequence(Text["" + (Element[listB, i]), (10 * i - 6, Element[listB, i] / m + 1)], i, 1, 4)
b = BarChart({5, 15, 25, 35}, listB / m, 6)
α: Element[list1, k] + Element[list2, k] + Element[list3, k]
c = 3 (slider from 0 to 3, step 1)
q = Binomial(3, c)
t_{Main}: "$ 共投擲" + (LaTeX[n]) + "次$
$第" + (LaTeX[k]) + "次投擲出現" + (LaTeX[3 - α]) + "個正面" + (LaTeX[α]) + "個反面$
$若隨機變數X表出現正面的次數$
$P(X=" + (LaTeX[c]) + ")=C^3_" + (LaTeX[c]) + "\;\frac{1}{2^3}=\frac{" + (LaTeX[q]) + "}{8}$
$E(X)=3\cdot \frac{1}{8}+2\cdot\frac{3}{8}+1\cdot \frac{3}{8}=\frac{3}{2}$
$V(X)=[\;3^2\cdot \frac{1}{8}+2^2\cdot \frac{3}{8}+1^2\cdot \frac{3}{8}\;]-(\frac{3}{2})^2$
            $=\frac{3}{4}$
$\sigma=\sqrt{V(X)}=\frac{\sqrt{3}}{2}$"