Template:Random number/testcases

From WikiProjectMed
Jump to navigation Jump to search


Testing sandbox version compared to main version

Clic purge to get new ouputs.
Code Result with sandbox template Result with main template Note
{{Random number}} 57 59 default parameters (results range is 0..99)
{{Random number|100|189|67}} 15 (KO) 59 (ok) should be same as above (the default seed depends on current day of year, the default prime is 67)
{{Random number|10000}} 9221 3359 new parameters (results range in 0..9999)
{{Random number|10000|189|67}} 4943 (KO) 3359 (ok) Should be same as above
{{Random number|10000|189|61}} 1873 6761 (use another prime) this and others should all be different
{{Random number|10000|6}} 5657 1098 (varying the seed) note that the sequence is linear but the distance only depends on the value of the default prime (67)
{{Random number|10000|5}} 9435 1031
{{Random number|10000|4}} 89 964
{{Random number|10000|3}} 1325 897
{{Random number|10000|2}} 3927 830
{{Random number|10000|1}} 3297 763
{{Random number|10000|0}} 1744 696
{{Random number|10000|6|2}} 9677 1823 (varying the seed) with a small prime (2) should still get distinct values in the linear sequence
{{Random number|10000|5|2}} 7869 1821
{{Random number|10000|4|2}} 1648 1819
{{Random number|10000|3|2}} 9835 1817
{{Random number|10000|2|2}} 3614 1815
{{Random number|10000|1|2}} 7397 1813 (varying now the prime number) should get distinct non-linear sequences
{{Random number|10000|1|3}} 3222 2719
{{Random number|10000|1|5}} 2641 4531
{{Random number|10000|1|7}} 784 6345
{{Random number|10000|1|11}} 3506 9970
{{Random number|10000|1|13}} 7105 1782
{{Random number|10000|1|17}} 5276 5406
{{Random number|10000|1|19}} 8067 7232
{{Random number|10000|1|23}} 2838 857
{{Random number|10000|1|29}} 1025 6287
{{Random number|10000|1|31}} 1221 8100
{{Random number|10000|1|37}} 8373 3545
{{Random number|10000|1|41}} 6780 7170
{{Random number|10000|1|43}} 4967 8995
{{Random number|10000|1|47}} 4507 2625
{{Random number|10000|1|51}} 2524 6210
{{Random number|10000|1|53}} 1903 8019
{{Random number|10000|1|59}} 4180 3455
{{Random number|10000|1|61}} 1426 5293
{{Random number|10000|1|67}} 800 763
{{Random number|10000|1|71}} 4782 4365
{{Random number|10000|1|73}} 2771 6139
{{Random number|10000|1|79}} 6549 1590

Sandbox notes

This version uses fmod builtin operator (no longer need of Template:Mod) and the largest Mersenne prime (231−1) that fits in 32 bits.

This Mersenne prime is chosen to offer equal distribution when reducing the number of digits (better than bitmasking by an exact power of 2).

The next Mersenne prime (261−1) is too large to fit in 64-bit integers for computing products by reasonable primes (we could only use 2, 3, 5 or 7), or even just in the 52 bits of precision of a double float (used by #expr).