tags: rBasicLearning
二項分布のグラフを作る
表の出る確率が0.8のコインを3回投げた時の二項分布のグラフ
グラフ化
x <- 0:3
n <- 3
p <- 0.8
plot(x, dbinom(x,n,p))
plot(x, dbinom(x,n,p), type="h")
二項分布の式
二項分布の定義式は、
$$f(x) = {}_n \mathrm{C} _r \cdot p^x \cdot (1 - p)^{n - x}$$
$n = 3$, $p = 0.8$より
$$f(x) = {}_3 \mathrm{C} _r \cdot (0.8)^x \cdot (1 - 0.8)^{3 - x}$$
これより、
$f(0) = 1\cdot1\cdot(0.2)^3 = 0.008$
$f(1) = 3\cdot0.8\cdot(0.2)^2 = 0.096$
$f(2) = 3\cdot(0.8)^2\cdot0.2 = 0.384$
$f(3) = 1\cdot(0.8)^3\cdot1 = 0.512$