View Full Version : computing with random generators (MATLAB)
Pythagorean
Jul4-11, 12:02 PM
So I ran an ODE solver with an additional, random (using randn) injected input.
Then I took the same ODE solver and the same random line, and multiplied it by 5, so now I have (5*randn). The runtime is already ten times as long (and still not finished). Why does it take so much longer to compute larger random values?
MRFMengineer
Jul12-11, 11:17 AM
Hmm, I checked this, the 5*randn line takes ~30% longer to compute on my machine.
tic
x=randn(5000);
toc
tic
y=5*randn(5000);
toc
Pythagorean
Jul13-11, 11:44 AM
Hmm, I checked this, the 5*randn line takes ~30% longer to compute on my machine.
tic
x=randn(5000);
toc
tic
y=5*randn(5000);
toc
Hrm good thought, I didn't expect it to be that simple... I thought maybe because my equations were nonlinear and chaotic that I was causing weird bifurcations that lead to regimes that were more computationally intensive.
I do notice that computing a static regime (nothing changing) is a lot faster than computing a chaotic regime, even though I'm using the same system (the parameter values are what's different).
I will tic toc my program with and without randn and see if that accounts for the majority of it. I never had randn there at all before, so I'll have to see what the effect of the whole function is, not just the *5 increase. Really thought it would have something to do with the ODE solver.
I'm curious about what equations you're using. By "input", ie. the thing you are varying with the random number generator, do you mean the initial conditions?
Any number produced by randn can also be produced by 5*randn since its a normal distribution, if it takes longer, it's probably because 5*randn is more likely to give a number of large magnitude which might happen to lead to a more computationally intensive region.
But I don't think there can be any sort of coupling between the random number generator and the chaotic equation. You're simply changing the likely range of initial conditions which changes the likely computation time of the solver.
5*randn takes 38% longer on my machine too.
Pythagorean
Jul15-11, 05:13 PM
I'm curious about what equations you're using.
a network of electrophysiological neurons. So one neuron is 2-D, but once you couple N neurons together, you have a 2*N-D system (generally on the order of hundreds to thousands of dimensions in my case)
Specifically:
http://en.wikipedia.org/wiki/Morris–Lecar_model
By "input", ie. the thing you are varying with the random number generator, do you mean the initial conditions?
It's actually a parameter (the injected current, I, in the model above).
Any number produced by randn can also be produced by 5*randn since its a normal distribution, if it takes longer, it's probably because 5*randn is more likely to give a number of large magnitude which might happen to lead to a more computationally intensive region.
That's what my intuition was.
But I don't think there can be any sort of coupling between the random number generator and the chaotic equation. You're simply changing the likely range of initial conditions which changes the likely computation time of the solver.
Not changing the initial conditions, changing the current injected at every time step for every neuron in the system.
5*randn takes 38% longer on my machine too.
Unfortunately, in my case, going from 1*randn to 5*randn more than double my time. I can't even quantify it (besides >200%) since I wasn't patient enough for it.
Next time I play with it, I'll do some more investigating and report back if I figure it out.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.