La loi géométrique

Fondements de la probabilité en R

David Robinson

Chief Data Scientist, DataCamp

Simuler l'attente jusqu'à pile

flips <- rbinom(100, 1, .1)
flips
#  [1] 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
# [16] 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
which(flips == 1)
# [1] 8 27 44 55 82 89
which(flips == 1)[1]
# [1] 8
Fondements de la probabilité en R

Répéter des simulations

which(rbinom(100, 1, .1) == 1)[1]
# [1] 28
which(rbinom(100, 1, .1) == 1)[1]
# [1] 4
which(rbinom(100, 1, .1) == 1)[1]
# [1] 11
replicate(10, which(rbinom(100, 1, .1) == 1)[1])
# [1] 22 12  6  7 35  2  4 44  4  2
Fondements de la probabilité en R

Simuler avec rgeom

geom <- rgeom(100000, .1)
mean(geom)
# [1] 9.04376

$$X \sim \text{Geom}(p)$$

$$E[X]=\frac{1}{p}-1$$

Fondements de la probabilité en R

Passons à la pratique !

Fondements de la probabilité en R

Preparing Video For Download...