Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: Predictable random sequence

by BrowserUk (Patriarch)
on Sep 17, 2013 at 15:50 UTC ( [id://1054482]=note: print w/replies, xml ) Need Help??


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(); }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^6: Predictable random sequence
by choroba (Cardinal) on Sep 17, 2013 at 16:06 UTC
    I cannot see by inspection why (or even how) you get different behaviour on linux?
    Different versions of the module?
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      I'm looking at the code on CPAN and comparing it with my local copy and it has barely changed, and as far as I can tell there is no platform dependence that would explain why the OP is getting different results.

      In fact, beyond a single typedef and the name of a header file, I see no platform dependency at all.

      Quite how the OP gets the output he posted is beyond my understanding.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        I think this is clearly just a bug, fixed in this version: diff (see changelog and code).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1054482]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-24 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found