Quantcast
Viewing all articles
Browse latest Browse all 1015

more e’s [and R’s]

By xi’an

Alex Thiéry suggested debiasing the biased estimate of e by Rhee and Glynn truncated series method, so I tried the method to see how much of an improvement (if any!) this would bring. I first attempted to naïvely implement the raw formula of Rhee and Glynn

Image may be NSFW.
Clik here to view.
hat{mathfrak{e}} = sum_{n=1}^N {hat{e}_{n+1}-hat{e}_n}big/mathbb{P}(Nge n)

with a (large) Poisson distribution on the stopping rule N, but this took ages. I then realised that the index n did not have to be absolute, i.e. to start at n=1 and proceed snailwise one integer at a time: the formula remains equally valid after a change of time, i.e. n=can start at an arbitrary value and proceeds by steps of arbitrary size, which obviously speeds things up!

n=1e6
step=1e2 
lamb=1e2
rheest=function(use=runif(n)){
rest=NULL
pond=rpois(n,lamb)+1
imax=min(which((1:n)>n-pond))
i=1
while (i.01)
  if (space>0){ space=1/space}
     else{ space=3}
  teles=teles+(space-past)/(1-ppois(j-1,lamb))
  past=space
  }
 rest=c(rest,teles)
 i=i+step*m+1}
return(rest)}

For instance, the running time of the above code with n=10⁶ uniforms in use is

> system.time(mean(rheest(runif(n))))
utilisateur     système      écoulé 
      6.035       0.000       6.031 

If I leave aside the issue of calibrating the above in terms of the Poisson parameter λ and of the step size [more below!], how does this compare with Forsythe’s method? Very (very) well if following last week pedestrian implementation:

> system.time(mean(forsythe(runif(n))))
utilisateur     système      écoulé 
    146.115       0.000     146.044 

But then I quickly (not!) realised that proceeding sequentially through the sequence of uniform simulations was not necessary to produce independent realisations of Forsythe’s estimate: this R code takes batches of uniforms that are far enough to see a …read more

Source:: r-bloggers.com


Viewing all articles
Browse latest Browse all 1015

Trending Articles