Archive for exam

ultimate R recursion

Posted in Books, R, Statistics, University life with tags , , , , , , on January 31, 2012 by xi'an

One of my students wrote the following code for his R exam, trying to do accept-reject simulation (of a Rayleigh distribution) and constant approximation at the same time:

 p=length(y)/n #acceptance probability

which I find remarkable if alas doomed to fail! I wonder if there exists a (real as opposed to fantasy) computer language where you could introduce constants C and only define them later… (What’s rather sad is that I keep insisting on the fact that accept-reject does not need the constant C to operate. And that I found the same mistake in several of the students’ code. There is a further mistake in the above code when defining g. I also wonder where the 3 came from…)

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!

R [re-]exam

Posted in Books, R, Statistics, University life with tags , , , , on March 28, 2011 by xi'an

In what seems like an endless cuRse, I found this week I had to re-grade a dozen R exams a TA’s did not grade properly! The grades I (X) got are plotted below against those of my TA (Y). There is little connection between both gradings… As if this was not enough trouble, I also found exactly duplicated R codes in another R project around Introducing Monte Carlo methods with R that was returned a few weeks ago. Meaning I will have to draft a second round exam… (As Tom commented on an earlier post, team resolution of a given problem may be a positive attitude, but in the current case one student provided an A⁺⁺ answer, while two others clearly drafted an hasty resolution from the original.) Nonetheless, do not worry, I still love [teaching] R!


Posted in Kids, pictures, University life with tags , , on February 19, 2011 by xi'an

I was visiting Jean-Michel Marin over the past two days in order to finalise our paper on ABC model choice and I noticed this very special exam on his wall. It was a copy made by his son, who is currently learning his letters, of a true exam Jean-Michel was grading a few weeks ago. Even though the picture is over-zoomed, it is possible to identify the (correct!) resolution of the MLE of the upper bound of a uniform distribution. A very cute rendering that also qualifies as Art brut! (In the spirit of Pierre Ménard, Borges’ short story about re-creation)

R exam

Posted in R, Statistics, University life with tags , , , on January 30, 2011 by xi'an

I spent most of my Saturday perusing R codes to check the answers written by my students to the R exam I gave two weeks ago… The outcome is mostly poor, even though some managed to solve a fair part of the long problem. Except for the few hopeless cases who visibly never wrote a single line of R code before the exam, all students have managed the basics of R programming and graphics, if not of Monte Carlo approximations or of boostrapping. One of the problems involved the distribution of a disk area and I found that half of the [third year math!] students do not know the \pi R^2 formula! Although I had repeatedly told them about the good training in trying to solve Le Monde puzzles (as well as checking my posts about them), only one student found the solution to puzzle #49


Get every new post delivered to your Inbox.

Join 557 other followers