recursion

the large half now

October 28, 2012 | xi'an

The little half puzzle proposed a “dumb’ solution in that players play a minimax strategy. There are 34 starting values less than 100 guaranteeing a sure win to dumb players. If instead the players maximise their choice at each step, the R code looks like this: and there are now 66 (=100-34, indeed!) ... [Read more...]

Cross validated question

February 19, 2012 | xi'an

Another problem generated by X’validated (on which I spent much too much time!): given an unbiased coin that produced M heads in the first M tosses, what is the expected number of additional tosses needed to get N (N__M) consecutive heads? Consider the preliminary question of getting a ... [Read more...]

ultimate R recursion

January 31, 2012 | 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: which I find remarkable if alas doomed to fail! I wonder if there exists a (real as opposed to fantasy) computer language ... [Read more...]

More Recursion in R

May 26, 2009 | R Tips

I found another gem in R today. Earlier I commented about how R could do recursion, something that I love. I write some pretty complicated recursion functions in my research, but I also have a bad habit of compulsively reorganizing things. Now I've c... [Read more...]

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)