Mercurial > octave
changeset 28598:43c285a20829
Update documentation of the random number generator (bug #58800).
* rand.cc (Frand): Update documentation for the initialization of the random
number generator according to changes in a61b651914d6.
author | Markus Meisinger <chloros2@gmx.de> |
---|---|
date | Sat, 25 Jul 2020 21:09:53 +0200 |
parents | a61b651914d6 |
children | 41ded587493a |
files | libinterp/corefcn/rand.cc |
diffstat | 1 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/rand.cc Thu Jul 23 14:24:46 2020 +0200 +++ b/libinterp/corefcn/rand.cc Sat Jul 25 21:09:53 2020 +0200 @@ -388,12 +388,14 @@ @leq{} 625 for @var{v}. This new state will be a hash based on the value of @var{v}, not @var{v} itself. -By default, the generator is initialized from @code{/dev/urandom} if it is -available, otherwise from CPU time, wall clock time, and the current -fraction of a second. Note that this differs from @sc{matlab}, which -always initializes the state to the same state at startup. To obtain -behavior comparable to @sc{matlab}, initialize with a deterministic state -vector in Octave's startup files (@pxref{Startup Files}). +By default, the generator is initialized by contributing entropy from the +wall clock time, the CPU time, the current fraction of a second, the process +ID and---if available---up to 1024 bits from the C++ random numbers source +@code{random_device}, which might be non-deterministic (implementation +specific). Note that this differs from @sc{matlab}, which always initializes +the state to the same state at startup. To obtain behavior comparable to +@sc{matlab}, initialize with a deterministic state vector in Octave's startup +files (@pxref{Startup Files}). To compute the pseudo-random sequence, @code{rand} uses the Mersenne Twister with a period of @math{2^{19937}-1}