Skip to content
Prev 199541 / 398502 Next

MCMC gradually slows down

Change that theta <- c() to
      theta <- numeric(n)
and it will go faster.  Growing datasets
can result in a lot of unnecessary memory
management.  The original had an obvious
quadratic quality in the plot of n vs. MHastings(n,.2,2)
and preallocating theta to its final length
made it look linear up to n=100000 and at n=100000
the time for the original was 35 seconds vs 3.75
for the preallocated version.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com