blackwinter / rb-gsl

Ruby interface to the GNU Scientific Library [Ruby 2.x and GSL 1.16 compatible fork of the gsl gem]
https://blackwinter.github.io/rb-gsl
Other
27 stars 7 forks source link

Random is not random? #13

Closed czarcar closed 9 years ago

czarcar commented 9 years ago

Library version: 1.15.3 Ruby version: 1.9.1 OS: Ubuntu 14.04

Each time I want to get a random number each new instance generates the same set. Verified by running /examples/random/gaussian.rb several times. The graph always looks exactly the same.

My test:

rng = GSL::Rng.alloc
=> GSL::Rng
rng.gaussian
=> 0.13391860811867587

rng = GSL::Rng.alloc
=> GSL::Rng
rng.gaussian
=> 0.13391860811867587 #same as first result

Am I misunderstanding something?

blackwinter commented 9 years ago

This is to be expected:

If the generator is seeded with the same value of s on two different runs, the same stream of random numbers will be generated by successive calls to the routines below. If different values of s >= 1 are supplied, then the generated streams of random numbers should be completely different.

https://www.gnu.org/software/gsl/manual/html_node/Random-number-generator-initialization.html