Sample Questions 01

Consider the following probability density function (pdf) over the support $(0,1)$:

\begin{equation} f(x) = \begin{cases} 4x^3 & \text{if } 0 < x < 1 \ 0 & \text{otherwise} \end{cases} \end{equation}

rf <- function(n) {
  U <- runif(n)
  X <- U^(1/4)

Write a function called rf, that generates i.i.d observations from this pdf. It should take in exactly one argument, $n$, that determines how many random variates to return. For instance:

rf(n = 5)

Now generate 10,000 random variates from this pdf and store them in a vector named X.

Your script must generate a function named rf and a vector named X.

Try the autoharp package in your browser

Any scripts or data that you put into this service are public.

autoharp documentation built on May 30, 2021, 1:07 a.m.