help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sampling from two instances of a random number generator


From: Søren Hauberg
Subject: Re: sampling from two instances of a random number generator
Date: Sun, 25 May 2008 22:28:37 +0200

søn, 25 05 2008 kl. 22:18 +0200, skrev Søren Hauberg:
>   function retval = myrand (sz, state)
>     rand ("state", state);
>     retval = rand (sz);
>   endfunction

Aarrghh, posted the wrong function. It should of course only set the
state once. So, something like this should do:

  function retval = myrand (sz, state),
    persistent static_state = [];
    if (isempty (static_state))
      static_state = state;
      rand ("state", state);
    endif
    retval = rand (sz);
  endfunction

Søren

P.S. This code isn't really tested, so you should check it before using
it :-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]