Module 6 assignment
np=100×0.95=95np = 100/ x 0.95 = 95np=100×0.95=95
nq=100×0.05=5nq = 100 / x 0.05 = 5nq=100×0.05=5
1. both np≥5np ≥ 5np≥5 and nq≥5nq ≥ 5nq≥5, the sample proportion does have an approximately normal distribution.
2 . The smallest it could is 100. N ≥ (5/95, 5/0.05) =max 5.263
C
rbinom(n, size, prob) is designed for binomial trials. For coin tosses, use rbinom(n, 1, 0.5) to get 0 or 1 outcomes or rbinom(1, n, 0.5) to get the total number of heads. It is vectorized, fast, and statistically correct for Bernoulli or binomial experiments.
sample(c("H","T"), n, replace=TRUE, prob=c(0.5,0.5)) also works, but it simulates categorical draws, then you count heads yourself. It is more code and less direct for binomial counts.
Bottom line for probability problems with coin flips: Use rbinom. It maps directly to the binomial model and is simpler for counts or 0 1 draws
Comments
Post a Comment