[R] runtime on ising model

Jim Lemon jim at bitwrit.com.au
Tue Oct 26 12:22:10 CEST 2010


On 10/26/2010 04:50 PM, Michael D wrote:
> So I'm in a stochastic simulations class and I having issues with the amount
> of time it takes to run the Ising model.
>
> I usually don't like to attach the code I'm running, since it will probably
> make me look like a fool, but I figure its the best way I can find any bits
> I can speed up run time.
>
> As for the goals of the exercise:
> I need the state of the system at time=1, 10k, 100k, 1mill, and 10mill
> and the percentage of vertices with positive spin at all t
>
> Just to be clear, i'm not expecting anyone to tell me how to program this
> model, cause I know what I have works for this exercise, but it takes far
> too long to run and I'd like to speed it up by replacing slow operations
> wherever possible.
>
Hi Michael,
One bottleneck is probably the sampling. If it doesn't grab too much 
memory, setting up a vector of the samples (maybe a million at a time if 
10 million is too big - might be able to rewrite your sample vector when 
you store the state) and using k (and an offset if you don't have one 
big vector) to index it will give you some speed.

Jim



More information about the R-help mailing list