of length are thrown upon a wooden floor made of planks of width t ≥ and where the number of times the needles cross a plank separation (or line) is counted. The resulting proportion leads to an approximation of π since the probability of crossing a line is 2 /tπ. (This model assumes all planks are identical, parallel, and horizontal.) (a) Implement the following R code : BuffonsPi <- function(N=1000,D=50,L=.25){ # warning: L is the half-length numbhits <- function(A,B){ sum(abs(trunc(A[,2])-trunc(B[,2]))>0)} O <- runif(N,min=0,max=pi/2) #angle U <- L+runif(N)*(D*sqrt(1+apply(cbind(sin(O)^2, cos(O)^2),1,min))-2*L) C <- cbind(U*cos(O),U*sin(O)) # centre A <- C+L*cbind(cos(O),sin(O)) # endpoint A B <- C-L*cbind(cos(O),sin(O)) # endpoint B return(2*2*L*N/numbhits(A,B)) } and explain the meaning of the outcome. (b) Explain why (or accept the fact that) this R code is only approximately solving Buffon’s original problem and identify from the R code what the corresponding values of and t are. (c) Study how the corresponding approximation of π converges with N, including a confidence interval in your evaluation. (d) Repeat the study with D=100, then with D=10. Exercise 2 Given the integral I = 3 2 e−x+5 (1 + x2) dx 1. Give the exact value of I using the R integrate function (up to a small precision). 2. Propose a Monte-Carlo method using an n-sample from an exponential distribution with λ = 1. Give the corresponding 95% confidence interval for i with n = 104. Ex- plain or show why using the Cauchy distribution would result in a worse estimator. 3. Propose an alternative method based on an n-sample from a uniform distribution. Give the corresponding 95% confidence interval for i with n equal to the previous exercise. 4. Establish which method is better by graphical (plotting the evolution of both esti- mators as n increase) and numerical means.