Strange behaviour of Rb-Gsl random numbers (Windows one-clic

Dear all,

I’ve installed Rb-gsl for the Ruby-one click installer,
and tried GSL::Rng.new.uniform to get a random number.
This works, but always gives the same number:

require “gsl”

res=[]
for k in 0…20
res<<GSL::Rng.new.uniform
end
p res

res=[0.999741748906672, 0.999741748906672, 0.999741748906672,
0.999741748906672, 0.999741748906672, 0.999741748906672,
0.999741748906672,
0.999741748906672, 0.999741748906672, 0.999741748906672,
0.999741748906672,
0.999741748906672, 0.999741748906672, 0.999741748906672,
0.999741748906672,
0.999741748906672, 0.999741748906672, 0.999741748906672,
0.999741748906672,
0.999741748906672, 0.999741748906672]

Why ?

Thank you,

best regards,

Axel

On Wed, 7 Jun 2006 [email protected] wrote:

res=[]
0.999741748906672, 0.999741748906672]

Why ?

you have to specify what kind of random number generator you want. try
this

irb(main):023:0> r = GSL::Rng.alloc Rng::TAUS, 1
=> GSL::Rng

irb(main):024:0> Array.new(20).map{ r.uniform }
=> [0.186914603225887, 0.951039797859266, 0.545435771113262,
0.0746261349413544, 0.22921886225231, 0.522971297148615,
0.0927675529383123,
0.511819139821455, 0.339204750722274, 0.793815617682412,
0.00488071935251355,
0.342924846103415, 0.296411268645898, 0.933765491936356,
0.208252872806042,
0.0223858365789056, 0.256050609983504, 0.684481433359906,
0.983118103351444,
0.441584395710379]

http://rb-gsl.rubyforge.org/rng.html

regards.

-a

On Wed, 7 Jun 2006 [email protected] wrote:

res=[]
0.999741748906672, 0.999741748906672]

Why ?

Thank you,

best regards,

Axel

i confirmed it - this works on my windows box:

jib:~ > ruby -r gsl -e’ include GSL; r = Rng.alloc Rng::TAUS, 1; p
Array.new(20).map!{ r.uniform } ’

[0.186914603225887, 0.951039797859266, 0.545435771113262,
0.0746261349413544,
0.22921886225231, 0.522971297148615, 0.0927675529383123,
0.511819139821455,
0.339204750722274, 0.793815617682412, 0.00488071935251355,
0.342924846103415,
0.296411268645898, 0.933765491936356, 0.208252872806042,
0.0223858365789056,
0.256050609983504, 0.684481433359906, 0.983118103351444,
0.441584395710379]

regards.

-a