Searched for tag PCG64 and found 1 results in 0.5 ms

PRNG: PCG64 in Perl

I found a PCG64 implementation that I was able to borrow and convert to pure Perl:

# PCG64 RXS-M-XS "simple" variant
#my $seeds = [12, 34];
#my $rand  = pcg64_perl($seeds);
sub pcg64_perl {
    my $seeds = $_[0];
    my $ret   = (($seeds->[0] >> (($seeds->[0] >> 59) + 5)) ^ $seeds->[0]);

    use integer;
    $ret *= 12605985483714917081;
    $seeds->[0] = $seeds->[0] * 6364136223846793005 + $seeds->[1];
    no integer;

    $ret = ($ret >> 43) ^ $ret;

    return $ret;
}

Update: Bonus points because it's really fast:

-               Rate  xoro256**      PCG32 Splitmix64      PCG64
xoro256**  1538462/s         --       -53%       -58%       -66%
PCG32      3289474/s       114%         --       -11%       -28%
Splitmix64 3703704/s       141%        13%         --       -19%
PCG64      4545455/s       195%        38%        23%         --
Tags:
Leave A Reply