**H**ere are two exercises I wrote for my R mid-term exam in Paris-Dauphine around Buffon’s needle problem. In the end, the problems sounded too long and too hard for my 3rd year students so I opted for softer questions. So recycle those if you wish (but do not ask for solutions!)

## Archive for Introduction to Monte Carlo Methods with R

## Buffon needled R exams

Posted in Books, Kids, R, Statistics, University life with tags Buffon's needle, Introduction to Monte Carlo Methods with R, mid-term exams, Paris, R, R exam, simulation, Université Paris Dauphine on November 25, 2013 by xi'an## R exam

Posted in Kids, pictures, Statistics, University life with tags exam, harmonic mean estimator, Introduction to Monte Carlo Methods with R, Méthodes de Monte-Carlo avec R, Monte Carlo methods, R, simulation, Université Paris Dauphine on November 28, 2011 by xi'an**F**ollowing a long tradition (!) of changing the *modus vivendi* of each exam in our exploratory statistics with R class, we decided this year to give the students a large collection of exercises prior to the exam and to pick five among them to the exam, the students having to solve two and only two of them. (The exercises are available in French on my webpage.) This worked beyond our expectations in that the overwhelming majority of students went over all the exercises and did really (too) well at the exam! Next year, we will hopefully increase the collection of exercises and also prohibit written notes during the exam (to avoid a possible division of labour among the students).

**I**ncidentally, we found a few (true) gems in the solutions, incl. an harmonic mean resolution of the approximation of the integral

since some students generated from the distribution with density *f* proportional to the integrand over [2,∞) [a truncated gamma] and then took the estimator

although we expected them to simulate directly from the exponential and average the sample to the fourth power… In this specific situation, the (dreaded) harmonic mean estimator has a finite variance! To wit;

> y=rgamma(shape=5,n=10^5) > pgamma(2,5,low=FALSE)*gamma(5) [1] 22.73633 > integrate(f=function(x){x^4*exp(-x)},2,Inf) 22.73633 with absolute error < 0.0017 > pgamma(2,1,low=FALSE)/mean(y[y>2]^{-4}) [1] 22.92461 > z=rgamma(shape=1,n=10^5) > mean((z>2)*z^4) [1] 23.92876

**S**o the harmonic means does better than the regular Monte Carlo estimate in this case!

## Méthodes de Monte-Carlo avec R [out]

Posted in Books, R, Statistics with tags Introduction to Monte Carlo Methods with R, Méthodes de Monte-Carlo avec R, translation on January 17, 2011 by xi'an**T**he translation of the book ** Introducing Monte Carlo Methods with R** is now published and out! I have received five copies in the mail yesterday, although it was not produced in time for my R class students to get it before the exam today. The book is still indicated on amazon.com as appearing in February, while amazon.fr announces the publication for January 20. I am very pleased with the quality of the output, in contrast with the first printing of the English version.