Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Computing with random generators (MATLAB)

  1. Jul 4, 2011 #1

    Pythagorean

    User Avatar
    Gold Member

    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?
     
  2. jcsd
  3. Jul 12, 2011 #2
    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
     
  4. Jul 13, 2011 #3

    Pythagorean

    User Avatar
    Gold Member

    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.
     
  5. Jul 14, 2011 #4
    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.
     
  6. Jul 15, 2011 #5

    Pythagorean

    User Avatar
    Gold Member

    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

    It's actually a parameter (the injected current, I, in the model above).

    That's what my intuition was.

    Not changing the initial conditions, changing the current injected at every time step for every neuron in the system.

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Computing with random generators (MATLAB)
Loading...