This technique (the split environment) is intended for single equations that span multiple lines, but it works for this purpose. Following code comes from the top answer here.
0 Comments
Finally, an explanation! File is attached right here.
After downloading and unzipped the source for a library that would allow me to simulate from a t-distribution, I wondered where to save it. Based on this note, I should save it in /Library/Java/Extensions/ because it's on the classpath. For other justification, see the link above.
This is a chapter from the book The Contribution of Young Researchers to Bayesian Statistics (November 2013). Available from Duke's network at this link. There's some really good stuff in here, including:
UPDATED: Ok, one thing that mitigates this is upping the factor on runif(1) to 1e6 or 1e7.
I apparently don't know enough about how set.seed() works in R. I'm fitting a model to some 2-D data using the EM algorithm. I do the fit a bunch of times (34 in this case) to look at sensitivity to starting values. I calculate AIC for each fit. To ensure I can run the fit again if I need to, I prefaced the call to my EM algorithm function by setting what I intended to be a random seed. The loop looks like this:
The loop starts at 5 because I happened to do 4 fits before realizing I was missing "set.seed()". Never mind that. The point is that the AICs for these fits cycle around (starting with the 5th). Here's a plot of all 34 AICs:
The default random number generator in R is the Mersenne Twister whose period is $2^{19937}-1$. Call that $L$. The plot above could occur if the number of random number generations my call to the EM algorithm uses, call it $N$ - and $N$ must not depend on the number of iterations needed before convergence, since can vary by fit - the plot above could happen if $L/N=7$. But that's impossible as $N$ is nowhere near that high.
What's going on? |
Categories
All
Archives
December 2016
AboutThis blog is mainly for statistics, R, or Duke-related stuff that is not directly relating to research activity. |