Pseudo-random numbers/Splitmix64: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: added the computer programming language REXX.)
m (→‎{{header|REXX}}: changed output format, reduce the number of decimal digits for calculations.)
Line 307: Line 307:
=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX program generates pseudo─random numbers using the split mix 64 bit method.*/
<lang rexx>/*REXX program generates pseudo─random numbers using the split mix 64 bit method.*/
numeric digits 400 /*ensure enough decimal digs for mult. */
numeric digits 200 /*ensure enough decimal digs for mult. */
parse arg n reps pick seed1 seed2 . /*obtain optional arguments from the CL*/
parse arg n reps pick seed1 seed2 . /*obtain optional arguments from the CL*/
if n=='' | n=="," then n= 5 /*Not specified? Then use the default.*/
if n=='' | n=="," then n= 5 /*Not specified? Then use the default.*/
Line 330: Line 330:
say
say
if reps==0 then exit 0 /*stick a fork in it, we're all done. */
if reps==0 then exit 0 /*stick a fork in it, we're all done. */
say center('#', w) " count of pseudo─random #"
say center('#', w) " count of pseudo─random #"
say copies('═', w) " ══════════════════════════"
say copies('═', w) " ════════════════════════════"
state= seed2 /* " the state to seed #2. */
state= seed2 /* " the state to seed #2. */
@.= 0; div= pick / 2**64 /*convert division to inverse multiply.*/
@.= 0; div= pick / 2**64 /*convert division to inverse multiply.*/
Line 340: Line 340:


do #=0 for pick
do #=0 for pick
say right(#':', w)" " right(commas(@.#), 14) /*show count of a random num.*/
say right(#':', w)" " right(commas(@.#), 15) /*show count of a random num.*/
end /*#*/
end /*#*/
exit 0 /*stick a fork in it, we're all done. */
exit 0 /*stick a fork in it, we're all done. */
Line 367: Line 367:
5: 16,408,922,859,458,223,821
5: 16,408,922,859,458,223,821


# count of pseudo─random #
# count of pseudo─random #
═══ ════════════════════════════
═══ ══════════════════════════
0: 20,027
0: 20,027
1: 19,892
1: 19,892
2: 20,073
2: 20,073
3: 19,978
3: 19,978
4: 20,030
4: 20,030
</pre>
</pre>