R includes distributions via d*, p*, q*, r* functions—density, probability, quantile, and random generation for normal, binomial, and more.
Normal distribution
print(pnorm(1.96))
print(qnorm(0.975))
set.seed(42)
print(rnorm(5))
Reproducible randomness
set.seed() fixes pseudo-random streams—critical for reproducible simulations and tests.
Important interview questions and answers
- Q: What does pnorm give?
A: Cumulative probability P(X <= x) for the standard normal by default. - Q: Why set.seed?
A: Same seed yields identical random draws—needed for reproducible research.
Self-check
- What prefix generates random draws?
- What does qnorm(0.975) represent?
Tip: Always set.seed() before simulations you publish or regression-test.
Interview prep
- rnorm vs rbinom?
rnormcontinuous normal draws;rbinomdiscrete binomial trials.