Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^5: Predictable random sequence

by BrowserUk (Pope)
on Sep 17, 2013 at 15:50 UTC ( #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.


Comment on Re^5: Predictable random sequence
Download Code
Re^6: Predictable random sequence
by choroba (Abbot) 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
Node Status?
node history
Node Type: note [id://1054482]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-09-20 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls