This is an exam. You can use any written resource and the internet but you can not discuss the exam with anyone!

The uploaded file should be called final.Rmd

Problem 1

Generate data from a Cauchy random variable with density \(f(x)=1/[\pi(1+x^2)]\) using two different methods discussed in class. Verify your solution by drawing the histogram with the density.

Problem 2

Generate data from the density proportional to

\[g(x, y)=\sin(\pi x/2)\frac{\Gamma(2x+2)}{\Gamma(x+1)^2}[y(1-y)]^x;0<x,y<1\]

using the runif command only. Verify your solution by drawing the histograms of the marginals with their densities.

Problem 3

Use simulation to find

\[\int_{-\infty}^\infty \int_{x-1}^{x+1} e^{-x^2}\sqrt{x^2+y^2} \text{ } dy \text{ }dx\]