事件 A 与事件 B 的概率

R 中的概率基础

David Robinson

Chief Data Scientist, DataCamp

事件 A:"正面朝上"

A = 1

A = 0

R 中的概率基础

事件 A 与 B:两枚不同的硬币

A = 1

A = 0

B = 1

B = 0

R 中的概率基础

A 与 B 的概率

$$\Pr(A \text{ and } B) = \Pr(A) \cdot \Pr(B)$$

R 中的概率基础

模拟两次掷币

A <- rbinom(100000, 1, .5)
B <- rbinom(100000, 1, .5)
A & B
# [1]  FALSE TRUE FALSE  FALSE...
mean(A & B)
[1] 0.24959

$$\Pr(A \text{ and } B)=\Pr(A) \cdot \Pr(B)$$

$$\Pr(A \text{ and } B)=.5 \cdot .5=.25$$

A <- rbinom(100000, 1, .1)
B <- rbinom(100000, 1, .7)
A & B
# [1]  FALSE FALSE FALSE  FALSE...
mean(A & B)
[1] 0.07043

$$\Pr(A \text{ and } B)=\Pr(A) \cdot \Pr(B)$$

$$\Pr(A \text{ and } B)=.1 \cdot .7=.07$$

R 中的概率基础

Passons à la pratique !

R 中的概率基础

Preparing Video For Download...