[This article was first published on

**R – Xi’an’s Og**, and kindly contributed to

R-bloggers]. (You can report issue about the content on this page

here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.

A challenge found on the board of the coffee room at CEREMADE, Université Paris Dauphine:

*When sampling with replacement three numbers in {0,1,…,N}, what is the probability that their average is (at least) one of the three?*

With a (code-golfed!) brute force solution of

mean(!apply((a<-sample(0:n,3e6,rep=T),3)),2,mean)-apply(a,2,median))

producing a graph pretty close to 3N/2(N+1)² (which coincides with a back-of-the-envelope computation):

*Related*

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook…