Woops. Sorry, Professor Feller!
. set obs 50
. gen i = _n
. gen double p = 1 - 1/365
. replace p = p[_n - 1] * (1 - _n / 365) in 2/l
. replace p = 1 - p
. scatter p i
Thanks for that trick, Nick. I wasn't aware that you could do recurrence
relations in Stata that way. I always somehow assumed that the -replace-
command in Stata created a whole new variable as a result, assigned its
values on the basis of pre-existing variables, and then discarded the old
variable and put the new one in its place. Evidently, it doesn't do that,
and instead writes directly to the old variable, observation by
observation, using the previous observation(s) as input if asked to do so.
This trick will no doubt be useful next time I need to do a recurrence
relation. I have noted, of course, that the last character in the 4th line
is a l (the lower case version of L), and not a 1 (the digit one).