Probability and Statistics: Exercises


1. Uniform distribution. The uniform distribution assigns equal probability to all intervals of the same length within the distribution's support. Using the function runif(n, min, max), draw 25 observations from a uniform distribution with a minimum of -1 and a maximum of 1. Plot a histogram of your draws using hist().


# Draw from uniform distribution. draws <- ___ # Plot histogram of observations. ___ # Draw from uniform distribution. draws <- runif(25, -1, 1) # Plot histogram of observations. hist(draws) test_error() test_function("runif", incorrect_msg="Did you use the `runif()` function?") test_function("hist", incorrect_msg="Did you use `hist()` to plot a histogram?") success_msg("Excellent work. What do you notice about the distribution of your draws?")
Did you set the parameters of the runif() correctly?

Previous Exercise Next Exercise