Jump to content

Template:Random number/testcases

From Wikipedia, the free encyclopedia

Testing sandbox version compared to main version

[edit]
Clic purge to get new ouputs.
Code Result with sandbox template Result with main template Note
{{Random number}} 48 69 default parameters (results range is 0..99)
{{Random number|100|363|67}} 30 (KO) 69 (ok) should be same as above (the default seed depends on current day of year, the default prime is 67)
{{Random number|10000}} 4160 1969 new parameters (results range in 0..9999)
{{Random number|10000|363|67}} 4710 (KO) 1969 (ok) Should be same as above
{{Random number|10000|363|61}} 7547 9255 (use another prime) this and others should all be different
{{Random number|10000|6}} 3687 8050 (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}} 9834 7983
{{Random number|10000|4}} 2435 7916
{{Random number|10000|3}} 7945 7849
{{Random number|10000|2}} 8502 7782
{{Random number|10000|1}} 4754 7715
{{Random number|10000|0}} 782 7648
{{Random number|10000|6|2}} 6922 3522 (varying the seed) with a small prime (2) should still get distinct values in the linear sequence
{{Random number|10000|5|2}} 3062 3520
{{Random number|10000|4|2}} 4795 3518
{{Random number|10000|3|2}} 942 3516
{{Random number|10000|2|2}} 6918 3514
{{Random number|10000|1|2}} 3227 3512 (varying now the prime number) should get distinct non-linear sequences
{{Random number|10000|1|3}} 4871 5268
{{Random number|10000|1|5}} 1099 8783
{{Random number|10000|1|7}} 2514 2293
{{Random number|10000|1|11}} 5983 9324
{{Random number|10000|1|13}} 2124 2828
{{Random number|10000|1|17}} 8264 9854
{{Random number|10000|1|19}} 8819 3370
{{Random number|10000|1|23}} 4965 403
{{Random number|10000|1|29}} 1115 950
{{Random number|10000|1|31}} 6692 4446
{{Random number|10000|1|37}} 3392 4977
{{Random number|10000|1|41}} 6512 2002
{{Random number|10000|1|43}} 1265 5542
{{Random number|10000|1|47}} 7410 2567
{{Random number|10000|1|51}} 9142 9592
{{Random number|10000|1|53}} 5283 3117
{{Random number|10000|1|59}} 797 3655
{{Random number|10000|1|61}} 6933 7173
{{Random number|10000|1|67}} 3079 7715
{{Random number|10000|1|71}} 9251 4707
{{Random number|10000|1|73}} 9841 8240
{{Random number|10000|1|79}} 5916 8733

Sandbox notes

[edit]

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).