期望与方差

R 中的概率基础

David Robinson

Chief Data Scientist, DataCamp

分布的性质

R 中的概率基础

期望

$$X\sim \text{Binomial}(\text{size},p)$$

$$E[X]=\text{size} \cdot p$$

flips <- rbinom(100000, 10, .5)
mean(flips)
# [1] 5.00196
mean(rbinom(100000, 100, .2))
# [1] 19.99053
R 中的概率基础

方差

$$X\sim \text{Binomial}(10, .5)$$

X <- rbinom(100000, 10, .5)
var(X)
# [1] 2.503735

$$\text{Var}(X)=\text{size} \cdot p \cdot (1 - p)$$

$$\text{Var}(X)=10\cdot .5 \cdot (1-.5)$$ $$=2.5\enspace\enspace\enspace$$

$$Y\sim \text{Binomial}(100, .2)$$

Y <- rbinom(100000, 100, .2)
var(Y)
# [1] 16.05621

$$\text{Var}(Y)=\text{size} \cdot p \cdot (1 - p)$$

$$\text{Var}(Y)=100 \cdot .2 \cdot (1 - .2)$$ $$=16$$

R 中的概率基础

期望与方差的规则

$$X\sim \text{Binomial}(\text{size},p)$$

$$E[X]=\text{size} \cdot p$$

$$\text{Var}(X)=\text{size} \cdot p \cdot (1 - p)$$

R 中的概率基础

Passons à la pratique !

R 中的概率基础

Preparing Video For Download...