Jump to content

Pseudo-random numbers/Combined recursive generator MRG32k3a: Difference between revisions

m
→‎{{header|Raku}}: minor style tweaks
m (→‎{{header|Raku}}: eliminate some intermediates, slightly more efficient)
m (→‎{{header|Raku}}: minor style tweaks)
Line 141:
constant m2 = 2**32 - 22853;
 
submethod BUILD ( Int :$seed where { 0 < $_* < m1 + 1 } = 1 ) { @!x1 = @!x2 = $seed, 0, 0; }
 
method next-int {
Line 155:
# Test next-int with custom seed
say 'Seed: 1234567; first five Int values:';
my $rng = MRG32k3a.new( :seed(1234567) );
.say for $rng.next-int xx 5;
 
Line 161:
# Test next-rat (since these are rational numbers by default)
say "\nSeed: 987654321; first 1e5 Rat values histogram:";
$rng = MRG32k3a.new( :seed(987654321) );
say ( ($rng.next-rat * 5).floor xx 100_000 ).Bag;
 
Line 185:
1012402089
1268414425
3353586348</pre>
</pre>
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.