MATLAB Computing with random generators (MATLAB)

AI Thread Summary
Using MATLAB, the discussion centers on the impact of scaling random inputs in an ODE solver. When multiplying the random input by 5, the computation time increased significantly, with one user noting a 30% longer runtime and others reporting even greater delays. The longer computation times are attributed to the increased likelihood of generating larger values, which may lead to more computationally intensive regions in the solver. The conversation also touches on the nature of the equations being solved, specifically in a network of electrophysiological neurons, and the distinction between changing initial conditions versus varying injected current. Further investigation into the effects of random input scaling on computation time is planned by the participants.
Pythagorean
Science Advisor
Messages
4,416
Reaction score
327
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?
 
Physics news on Phys.org
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
 
MRFMengineer said:
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.
 
MikeyW said:
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.
 

Similar threads

Replies
5
Views
2K
Replies
4
Views
1K
Replies
1
Views
5K
Replies
1
Views
4K
Replies
4
Views
1K
Replies
3
Views
3K
Replies
2
Views
3K
Back
Top