in reply to Re^4: Predictable random sequence
in thread Predictable random sequence
Hm. Intriguing. It seems that the Windows versions are doing the 'right thing'. Ie. ignoring the argument when you call rand and returning a random float 'tween 0 .. 1.
To get the equivalent behaviour of the built-in rand where the random float is multiplied by the argument, you need to import the function irand().
I cannot see by inspection why (or even how) you get different behaviour on linux?
It seems it should do the same thing as the Windows install:
sub rand { my ($self, $N) = @_; unless (ref $self) { Math::Random::MT::srand() unless defined $gen; $self = $gen; } return $self->genrand(); } sub irand { my ($self, $N) = @_; unless (ref $self) { $N = $self; Math::Random::MT::srand() unless defined $gen; $self = $gen; } return ($N || 1) * $self->genirand(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Predictable random sequence
by choroba (Cardinal) on Sep 17, 2013 at 16:06 UTC | |
by BrowserUk (Patriarch) on Sep 17, 2013 at 16:31 UTC | |
by vsespb (Chaplain) on Sep 18, 2013 at 15:40 UTC |