Computing with random generators (MATLAB)

Click For Summary

Discussion Overview

The discussion revolves around the performance impact of using random number generators in MATLAB, specifically comparing the execution time of an ODE solver when using different scales of random inputs. Participants explore the relationship between the magnitude of random values generated and the computational efficiency of solving nonlinear equations in chaotic systems.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant notes that using (5*randn) significantly increases the runtime of an ODE solver compared to using (randn), suggesting a tenfold increase in computation time.
  • Another participant confirms a 30% longer computation time for (5*randn) on their machine, prompting further investigation into the effects of the random input.
  • A participant speculates that the increase in runtime may be due to the nature of chaotic systems, where larger random values could lead to more computationally intensive regimes.
  • One participant inquires about the specific equations being used and clarifies that the random input refers to the injected current in a model of coupled neurons, rather than initial conditions.
  • It is suggested that while (5*randn) can produce values that are also generated by (randn), the larger values may lead to more complex computational scenarios, affecting the solver's performance.
  • Another participant expresses that the increase in computation time from (1*randn) to (5*randn) is more than double, indicating a significant impact on performance that they plan to investigate further.

Areas of Agreement / Disagreement

Participants generally agree that using larger random values leads to increased computation time, but the exact reasons for this increase remain debated. There is no consensus on whether the increase is solely due to the random number generator's output or if it is influenced by the chaotic nature of the equations being solved.

Contextual Notes

Participants mention the complexity of their systems, including nonlinear and chaotic dynamics, which may affect computation time. The discussion highlights the dependence on specific parameter values and the potential for varying computational intensity based on the range of random inputs.

Pythagorean
Science Advisor
Messages
4,430
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 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K