Le Monde puzzle [#743]

October 11, 2011

(This article was first published on Xi'an's Og » R, and kindly contributed to R-bloggers)

As Le Monde weekend has yet again changed its format (with so much more advertisements for luxurious items that I sometimes wonder whether or not this is the weekend edition of Le Monde!], it took me a while to locate the mathematical puzzle. The good news is there now is a science&techno leaflet with, at the end, the math puzzle! (Sorry, this is of no relevance for anyone but me!)

The problem of last week is loosely connected with random walks on a grid. Given a nxm grid, consider all the shortest length paths linking (0,0) with (n,m). They all are of length n+m and can be represented as a sequence of l‘s and d‘s (for left and down). The question amounts to compute the probability that two of those paths intersect “in the middle”, i.e. after (n+m)/2 steps if (n+m) is even, or share the edge from the (n+m-1)/2 node to the  (n+m+1)/2 node.

When (n+m) is even, if the meeting node is (i,j), with i+j=(n+m)/2, there are

{i+j \choose i}

moves from (0,0) to (i,j) and then again

{i+j \choose n-i}

moves from (i,j) to (n,m) (since the total number of down moves is n). The number of paths going from (0,0) to (n,m) through (i,j) is therefore

{i+j \choose i}\times{i+j \choose n-i}

and the probability of meeting in (i,j) is

\left\{{i+j \choose i}\times{i+j \choose n-i} \right\}^2/{n+m \choose n}^2\,,

hence the probability of meeting somewhere is

\sum_{i=0\vee (n-m)/2}^{n\wedge (n+m)/2}\left\{{i+j \choose i}\times{i+j \choose n-i} \right\}^2/{n+m\choose n}^2\,.

whose numerator is equal to

{(n+m)/2 \choose (n-m)/2}^2{}_4 F_3(-m, -m, -m/2-n/2, -m/2-n/2;1, -m/2+n/2+1, -m/2+n/2+1;1)

according to Wolfram alpha when n>m…. And to

{(m+n)\/2\choose n}^2 {}_4 F_3(-m/2-n/2, -m/2-n/2, -n, -n;1, m/2-n/2+1, m/2-n/2+1;1)

otherwise. Nothing we can compute in R, I am afraid. (Feel free to process the case when n+m is odd as an exercise!)

Now, the original problem involved a random choice of direction (left and down) at each node (if any), meaning all paths do not have the same probability. So here is a (plain) R code aiming at approximating the probability:




  for (t in 2:(n+m+1)){

    if (max(path[,1]-n,path[,2]-m)<0){

Filed under: R, Statistics Tagged: confluent hypergeometric function, R

To leave a comment for the author, please follow the link and comment on their blog: Xi'an's Og » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , ,

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)