January 5th, 2012, 4:34 pm
I'm running some rather computationally intensive monte carlo simulations of SDEs, and I am wondering what is more efficient:a) for a sample path of N steps, generate N normal random variables and then call their values at each step. e.g. (in Matlab)dW = sqrt(dt) * rand(1,N)for i = 1:NX = X + dW(1,i);endb) for a sample path of N steps, generate a single normal random variable at each time step. e.g. for i = 1:NdW = sqrt(dt) * rand(1,1)X = X + dW;endthe code is obviously more complicated than that. I just want to know which technique is more efficient. Technique a) is what I am currently using. But, I am concerned that I am using up more memory than I need to by storing a bunch of random variables that only get used one time.