## Vivons-nous pour être heureux ? [bacc. 2014]

Posted in Books, Kids with tags , , , , , on June 20, 2014 by xi'an

This year is my daughter’s final year in high school and she is now taking the dreaded baccalauréat exams. Just like a few hundred thousands French students. With “just like” in the strict sense since all students with the same major take the very same exam all over France… The first written composition is in the “mother of all disciplines”, philosophy, and the theme of one dissertation this year was “do we live to be happy?”. Which suited well my daughter as she was hoping for a question around that theme. She managed to quote Plato and Buddha, The Pursuit of Happiness and The Wolf of Wall-street… So sounded happy enough with her essay. This seemed indeed like a rather safe notion (as opposed to ethics, religion, politics or work), with enough material to fill a classical thesis-antithesis-synthesis plan (and my personal materialistic conclusion about the lack of predetermination in our lifes).

## Bayes at the Bac’ [again]

Posted in Kids, Statistics with tags , , , , , , , , on June 19, 2014 by xi'an

When my son took the mathematics exam of the baccalauréat a few years ago, the probability problem was a straightforward application of Bayes’ theorem.  (Problem which was later cancelled due to a minor leak…) Surprise, surprise, Bayes is back this year for my daughter’s exam. Once again, the topic is a pharmaceutical lab with a test, test with different positive rates on two populations (healthy vs. sick), and the very basic question is to derive the probability that a person is sick given the test is positive. Then a (predictable) application of the CLT-based confidence interval on a binomial proportion. And the derivation of a normal confidence interval, once again compounded by  a CLT-based confidence interval on a binomial proportion… Fairly straightforward with no combinatoric difficulty.

The other problems were on (a) a sequence defined by the integral

$\int_0^1 (x+e^{-nx})\text{d}x$

(b) solving the equation

$z^4+4z^2+16=0$

in the complex plane and (c) Cartesian 2-D and 3-D geometry, again avoiding abstruse geometric questions… A rather conventional exam from my biased perspective.

## 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:

fAR1=function(n){
u=runif(n)
x=rexp(n)
f=(C*(x)*exp(-2*x^2/3))
g=dexp(n,1)
test=(u<f/(3*g))
y=x[test]
p=length(y)/n #acceptance probability
M=1/p
C=M/3
hist(y,20,freq=FALSE)
return(x)
}


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!

## Examen

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