Issue #3104 has been updated by Yusuke Endoh.

Status changed from Open to Closed
Assigned to changed from Nobuyoshi Nakada to Marc-Andre Lafortune

Hi,

> 1) Seeding sometimes ignores the high bit of seed data.
>
>    Random.new((1<<64)-1).rand == Random.new((1 << 65) -1).rand 
>     # => true, should be false

I really agree that this is uncool.
But it should not be changed from three reasons.

A) compatibility
This feature is already released in 1.9.1:

  $ ruby-1.9.1-p378 -e 'srand((1 << 64)-1); p rand'
  0.0218256954012701
  $ ruby-1.9.1-p378 -e 'srand((1 << 65)-1); p rand'
  0.0218256954012701
  $ ./ruby -ve 'p Random.new((1 << 64)-1).rand'
  ruby 1.9.2dev (2010-04-21 trunk 27426) [i686-linux]
  0.021825695401270107

B) no guarantee for decorrelation
From what I hear, it is never guaranteed at for two random
sequences (generated from two different seeds) to be
uncorrelated.
The fact is also true for Mersenne Twister itself.

C) seed bias
As akr said, your patch has potential for bias.
This is because MSB of any Bignum always 1.
Incidentally, I prefer removing MSB to current implementation.


> 2) Treatment of negative seed values is currently platform dependent for all negative fixnums. From the same negative seed, the random sequence can be different on 32 bit platforms than on 64 bit ones.

Umm.  I bet portability beats compatibility in this case.
This patch has been already imported.  Thanks!

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3104

----------------------------------------
http://redmine.ruby-lang.org