Read R4DS chapter 19.
Solve the course Introduction to Writing Functions in R at DataCamp.
Complete the exercises in R4DS sections 19.2.1, 19.3.1, 19.4.4, 19.5.5.
If the stochastic variable \(X\) is uniformly distributed on \((a,b)\), then \(E(f(X))=\int_{a}^bf(x)/(b-a)\,dx\). This can be used in order to approximate integrals:
By the Law of Large Numbers, \(I\) will converge to \(\int_{a}^bf(x)\,dx\) as \(N\rightarrow\infty\) and can thus be viewed as a numerical approximation of the integral.
MC_int
that takes \(f\), \(a\), \(b\), \(N\) as inputs and returners \(I\)....
such that e.g. MC_int(dnorm, 0, 1, 10000, mean = 1, sd = 2)
integrates the density of an \(N(1, 2^2)\)-distribution from 0 to 1.Write a function
repertoire <- function(year) {
}
that returns a data frame with the sets of the Royal Dramatic Theatre in year year
(columns Play
, Opening_night
, Director
and Stage
). The sets for, e.g., the inaugural year 1908 can be found by scraping the table on http://www.dramaten.se/medverkande/rollboken/?category=date&query=1908.