Instructor: Colin Grudzien

## Instructions: We will work through the following series of activities as a group and hold small group work and discussions in Zoom Breakout Rooms. Follow the instructions in each sub-section when the instructor assigns you to a breakout room. ## Activities: To perform some integration techniques, we will want the following packages, ```{r} require(cubature) require(caTools) ``` ### Activity 1: Integration of density functions. Let $X$ be a random variable distributed according to a CDF $F$, defining the probability distribution. If $f$ is a continuous probability density function for that distribution, then $$\int_{-\infty}^x f(t)\mathrm{d}t = F(x) = P(X \leq x)$$ We will now show how this relationship can be computed in R with the integrate command. #### Question 1: Recalling the form of the density function and CDF for the normal, find out by how much the integrate function applied to the density differs from the built-in CDF function for calculating $P(X \leq 1)$ for $X\sim N(0,1)$. Call the `abs.error` variable to find the estimated error of the integral. Is the estimate too high or too low in this example? #### Question 2: Recalculate the above, but set the `rel.tol` keyword in the `integrate` function to `10e-10`. Now what is the result of the absolute difference with the `pnorm` calculation? How does the error estimate look in relationship to the difference with the `pnorm` value? #### Question 3: We now change the standard normal to the normal with $\mu=-10$ and $\sigma=5$. You must pass these arguments as keyword arguments in the `integrate` function, using the same keywords from the `dnorm` function. The `integrate` will pass these arguments to the integrand function if specified correctly. Try computing the integral of the density function for $N(-10,5)$ to compute $P(X\leq 1)$ using the `integrate` function with the default `rel.tol` argument and the `rel.tol=10e-10`. How do these approximate integrals compare to the value from the `pnorm` function?