## sans sérif & sans chevron

Posted in Books, R, Statistics, University life with tags , , , , , , , , , , , , on June 17, 2020 by xi'an
`{\sf df=function(x)2*pi*x-4*(x>1)*acos(1/(x+(1-x)*(x<1)))}`

As I was LaTeXing a remote exam for next week, including some R code questions, I came across the apparent impossibility to use < and > symbols in the sans-sérif “\sf” font… Which is a surprise, given the ubiquity of the symbols in R and my LaTeXing books over the years. Must have always used “\tt” and “\verb” then! On the side, I tried to work with the automultiplechoice LaTeX package [which should be renamed velomultiplechoice!] of Alexis Bienvenüe, which proved a bit of a challenge as the downloadable version contained a flawed file of automultiplechoice.sty! Still managed to produce a 400 question exam with random permutations of questions and potential answers. But not looking forward the 4 or 5 hours of delivering the test on Zoom…

## Terry Tao on Bayes… and Trump

Posted in Books, Kids, Statistics, University life with tags , , , , , , , on June 13, 2016 by xi'an

“From the perspective of Bayesian probability, the grade given to a student can then be viewed as a measurement (in logarithmic scale) of how much the posterior probability that the student’s model was correct has improved over the prior probability.” T. Tao, what’s new, June 1

An interesting and more Bayesian last question from Terry Tao is about what to do when the probabilities themselves are uncertain. More Bayesian because this is where I would introduce a prior model on this uncertainty, in a hierarchical fashion, in order to estimate the true probabilities. (A non-informative prior makes its way into the comments.) Of course, all this leads to a lot of work given the first incentive of asking multiple choice questions…

One may wonder at the link with scary Donald and there is none! But the next post by Terry Tao is entitled “It ought to be common knowledge that Donald Trump is not fit for the presidency of the United States of America”. And unsurprisingly, as an opinion post, it attracted a large number of non-mathematical comments.

## done! [#1]

Posted in Kids, pictures, University life with tags , , , , , , on January 16, 2016 by xi'an

After spending a few hours grading my 127 exams for most nights of this week, I am finally done with it! One of the exam questions was the simulation of XY when (X,Y) is a bivariate normal vector with correlation ρ, following the trick described in a X validated question asked a few months ago, namely that

XY≡R{cos(πU)+ρ}

but no one managed to establish this representation. And, as usual, some students got confused between parameters θ and observations x when writing a posterior density, since the density of the prior was defined in the exam with the dummy x, thereby recovering the prior as the posterior. Nothing terrible and nothing exceptional with this cohort of undergraduates. And now I still have to go through my second pile of exams for the graduate course I taught on Bayesian computational tools…

## Le Monde puzzle [#14]

Posted in R with tags , , , on May 14, 2011 by xi'an

Last week Le Monde puzzle (I have not received this week issue yet!) was about deriving an optimal strategy in less than 25 steps for finding the 25 answers to a binary multiple choice test, when at each trial, only the number of correct answers is known.

Hence, if the correct answers are y1,…,y25, and the first guess is x1,…,x25, all taking values in {0,1}, the value of

$(y_1-x_1)^2+\cdots+(y_{25}-x_{25})^2$

is available. Changing only x25 into (1-x25) leads to the knowledge of the corresponding y25. This takes two steps. However, if we keep changing each xi one at a time and downwards, in at most 24 steps, we know y25,…,y2, thus (y1-x1, hence y1. Indeed, we know the remaining yi‘s as soon as as the sum is either zero or the number of terms. This shows that there exists a strategy with 25 steps or less that provides the answer to the multiple choice test. If we are unlucky enough in our choice, can we reach the 25 steps? Here is a simulation experiment in R that explores this question, where the stopping rule is associated with all wrong or all right remaining answers.

```rangep=rep(0,25)

for (t in 1:10^6){

y=sample(c(0,1),25,rep=T)
x=sample(c(0,1),25,rep=T)
p=25
Delta=cumsum((x-y)^2)
while ((Delta[p]>0)&&(Delta[p]<p)){
p=p-1}

rangep[p]=rangep[p]+1
}
```

whose output is

```> rangep[1]/10^6
[1] 0.500851
> sum((25:1)*rangep)/10^6
[1] 24.00053
```

and the mode of the distribution of the p’s seems to be at 1, which means that in 50% of the cases, when eliminating/finding one yi at a time, we need to do the 25 steps. The average number of steps is furthermore 24. Mathematically, the distribution of the number of steps relates to the longest sequence with the same value in a Bernouilli experiment, which is a Geometric(1/2) truncated at 24. (Note that an earlier version with a basic R mistake wrongly concluded to a binomial fit! Also, I am not saying this is the optimal strategy, just one that satisfies the constraint.)