```
# germination test
p <- 0.93 # probability to germ (one individual seed)
n_seed <- 50 # number of seeeds per petri dish
repl <- 3 # number of replicates (no petri dishes per year)
# rbinom(n, size, prob)
y <- rbinom(n=repl, size = n_seed, prob = p)
y
p_hat <- (sum(y)/repl)/n_seed
p_hat
set.seed(170510) #this is another form of seed, a start for random numbers
#### simulation with 3 petri dishes and 10,000 "years"
repl <- 3 # number of replicates (no petri dishes per year)
p_hat <- numeric()
simul <- 10000 #numb of simulations (numb of "years")
for (i in 1:simul){
y <- rbinom(n=repl, size = n_seed, prob = p)
p_hat[i] <- (sum(y)/repl)/n_seed
}
mean(p_hat)
sd(p_hat)
mean(p_hat) + c(-1, 1)*1.96*sd(p_hat)
# 0.8888088 0.9707419 so it can at least vary from 88.8% to 97.1%
hist(p_hat)
#### simulation with 8 petri dishes
repl <- 8 # number of replicates (no petri dishes per year)
p_hat <- numeric()
simul <- 10000 #numb of simulations (numb of "years")
for (i in 1:simul){
y <- rbinom(n=repl, size = n_seed, prob = p)
p_hat[i] <- (sum(y)/repl)/n_seed
}
mean(p_hat)
sd(p_hat)
mean(p_hat) + c(-1, 1)*1.96*sd(p_hat)
#[1] 0.9043768 0.9557072 (most values from 90.4% to 95.5%)
hist(p_hat)
```