1. CONTOH SEDERHANA

dpois(x = 3, lambda = 5)
## [1] 0.1403739
0:12
##  [1]  0  1  2  3  4  5  6  7  8  9 10 11 12
dpois(x = 0:12, lambda = 5)
##  [1] 0.006737947 0.033689735 0.084224337 0.140373896 0.175467370 0.175467370
##  [7] 0.146222808 0.104444863 0.065278039 0.036265577 0.018132789 0.008242177
## [13] 0.003434240
barplot(dpois(0:12, 5), names.arg = 0:12, col = "red")

# 2. Menggunakan model probabilitas diskrit

genotype = c("AA","AO","BB","AO","OO","AO","AA","BO","BO",
             "AO","BB","AO","BO","AB","OO","AB","BB","AO","AO")
table(genotype)
## genotype
## AA AB AO BB BO OO 
##  2  2  7  3  3  2
genotypeF = factor(genotype)
levels(genotypeF)
## [1] "AA" "AB" "AO" "BB" "BO" "OO"
table(genotypeF)
## genotypeF
## AA AB AO BB BO OO 
##  2  2  7  3  3  2

#3 Uji coba Bernoulli

rbinom(15, prob = 0.5, size = 1)
##  [1] 0 0 0 1 0 0 1 0 1 0 0 0 1 1 0
rbinom(12, prob = 2/3, size = 1)
##  [1] 1 1 1 1 0 0 1 0 1 1 1 0

#4 Keberhasilan binomial penting

rbinom(1, prob = 2/3, size = 12)
## [1] 11
set.seed(235569515)
rbinom(1, prob = 0.3, size = 15)
## [1] 5
probabilities = dbinom(0:15, prob = 0.3, size = 15)
round(probabilities, 2)
##  [1] 0.00 0.03 0.09 0.17 0.22 0.21 0.15 0.08 0.03 0.01 0.00 0.00 0.00 0.00 0.00
## [16] 0.00
barplot(probabilities, names.arg = 0:15, col = "red")

#5 DISTRIBUSI POISSON

rbinom(1, prob = 5e-4, size = 10000)
## [1] 6
simulations = rbinom(n = 300000, prob = 5e-4, size = 10000)
barplot(table(simulations), col = "lavender")

## HASIL DARI 50 TES

load("./data/e100.RData")
barplot(e100, ylim = c(0, 7), width = 0.7, xlim = c(-0.5, 100.5),
  names.arg = seq(along = e100), col = "darkolivegreen")

REFERENSI :

https://www.huber.embl.de/msmb/01-chap.html#sec-generative-intro