## Buffon needled R exams

Posted in Books, Kids, R, Statistics, University life with tags , , , , , , , on November 25, 2013 by xi'an

Here 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!)

## slides for my simulation course

Posted in Books, Kids, R, Statistics, University life with tags , , , , , , , , on October 18, 2012 by xi'an

Similar to last year, I am giving a series of lectures on simulation jointly as a Master course in Paris-Dauphine and as a 3rd year course in ENSAE. The course borrows from both the books Monte Carlo Statistical Methods and from Introduction to Monte Carlo Methods with R, with George Casella. Here are the three series of slides I will use throughout the course this year, mostly for the benefit of the students:

(the last series is much improved when compared with an earlier version, thanks to Olivier Cappé!)

## R exam

Posted in Kids, pictures, Statistics, University life with tags , , , , , , , on November 28, 2011 by xi'an

Following 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).

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

$\int_2^\infty x^4 e^{-x}\,\text{d}x=\Gamma(5,2)$

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

$\dfrac{1-e^{-2}}{\frac{1}{n}\,\sum_{i=1}^n y_i^{-4}}\approx\dfrac{\int_2^\infty e^{-x}\,\text{d}x}{\mathbb{E}[X^{-4}]}\quad\text{when}\quad X\sim f$

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


So 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 , , on January 17, 2011 by xi'an

The 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.