Section 24 Vector: Sampling from distributions

  • Set the seed before random number generation: set.seed()

24.1 The Uniform Distribution

runif(n, min = 0, max = 1)

set.seed(1234)

x <- runif(n=10, min=2, max=10)

x


24.2 The Normal Distribution

rnorm(n, mean = 0, sd = 1)

set.seed(1234)

y <- rnorm(n=20, mean=10, sd=2)

y