Template:Rand: Difference between revisions

From The Pokemon Insurgence Wiki
(Testing Random)
 
m (Welp, that didn't work.)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<includeonly>{{Mod|(({{#time:U}}+({{{2|{{#time:z}}}}}))*({{{3|67}}})+({{NUMBEROFARTICLES:R}} mod ({{{3|67}}})))|{{{1|100}}}}}</includeonly><noinclude>
This template generates a pseudo-random integer between 0 and ''count''-1.
Please put all metadata in documentation page [[Template:Rand/doc]]  
 
</noinclude>
; Usage<nowiki>:</nowiki>
* <tt><nowiki>{{</nowiki>Rand<nowiki>|</nowiki></tt>''count''<tt><nowiki>|</nowiki></tt>''seed''<tt><nowiki>|</nowiki></tt>''prime''<tt><nowiki>}}</nowiki></tt>
* All parameters are optional and have default values. They must be integers.
* The default ''count'' is 100 (so by default, this template generates values between 0 and 99) and must be non-zero.
* The default ''seed'' is <nowiki>{{#time:z}}</nowiki> (currently {{#time:z}}, i.e. the current day number in the year, at the time this page was last saved or purged from the cache) and can be set to any other integer value (used to generate distinct values on the same page).
* The default ''prime'' is 67 and should be a prime number above 17 (used to generate distinct values on the same page).
 
; Examples generating numbers between 0 and 999<nowiki>:</nowiki>
* <tt><nowiki>{{Rand|1000}}</nowiki></tt> = {{Rand|1000}}
* <tt><nowiki>{{Rand|1000}}</nowiki></tt> = {{Rand|1000}} (same day, same output)
* <tt><nowiki>{{Rand|1000|</nowiki>{{#time:z}}<nowiki>|67}}</nowiki></tt> = {{Rand|1000|{{#time:z}}|67}} (same as above)
* <tt><nowiki>{{Rand|1000|</nowiki>{{#time:z}}<nowiki>|61}}</nowiki></tt> = {{Rand|1000|{{#time:z}}|61}} (this and others should all be different)
* <tt><nowiki>{{Rand|1000|6}}</nowiki></tt> = {{Rand|1000|6}}
* <tt><nowiki>{{Rand|1000|5}}</nowiki></tt> = {{Rand|1000|5}}
* <tt><nowiki>{{Rand|1000|4}}</nowiki></tt> = {{Rand|1000|4}}
* <tt><nowiki>{{Rand|1000|3}}</nowiki></tt> = {{Rand|1000|3}}
* <tt><nowiki>{{Rand|1000|2}}</nowiki></tt> = {{Rand|1000|2}}
* <tt><nowiki>{{Rand|1000|1}}</nowiki></tt> = {{Rand|1000|1}}
* <tt><nowiki>{{Rand|1000|0}}</nowiki></tt> = {{Rand|1000|0}}
* <tt><nowiki>{{Rand|1000|1|17}}</nowiki></tt> = {{Rand|1000|0|17}} (varying the prime number)
* <tt><nowiki>{{Rand|1000|1|19}}</nowiki></tt> = {{Rand|1000|0|19}}
* <tt><nowiki>{{Rand|1000|1|23}}</nowiki></tt> = {{Rand|1000|0|23}}
* <tt><nowiki>{{Rand|1000|1|29}}</nowiki></tt> = {{Rand|1000|0|29}}
* <tt><nowiki>{{Rand|1000|1|31}}</nowiki></tt> = {{Rand|1000|0|31}}
* <tt><nowiki>{{Rand|1000|1|37}}</nowiki></tt> = {{Rand|1000|0|37}}
* <tt><nowiki>{{Rand|1000|1|41}}</nowiki></tt> = {{Rand|1000|0|41}}
* <tt><nowiki>{{Rand|1000|1|43}}</nowiki></tt> = {{Rand|1000|0|43}}
* <tt><nowiki>{{Rand|1000|1|47}}</nowiki></tt> = {{Rand|1000|0|47}}
* <tt><nowiki>{{Rand|1000|1|51}}</nowiki></tt> = {{Rand|1000|0|51}}
* <tt><nowiki>{{Rand|1000|1|53}}</nowiki></tt> = {{Rand|1000|0|53}}
* <tt><nowiki>{{Rand|1000|1|59}}</nowiki></tt> = {{Rand|1000|0|59}}
* <tt><nowiki>{{Rand|1000|1|61}}</nowiki></tt> = {{Rand|1000|0|61}}
* <tt><nowiki>{{Rand|1000|1|67}}</nowiki></tt> = {{Rand|1000|0|67}}
* <tt><nowiki>{{Rand|1000|1|71}}</nowiki></tt> = {{Rand|1000|0|71}}
* <tt><nowiki>{{Rand|1000|1|73}}</nowiki></tt> = {{Rand|1000|0|73}}
* <tt><nowiki>{{Rand|1000|1|79}}</nowiki></tt> = {{Rand|1000|0|79}}
 
; Note<nowiki>:</nowiki>
* Varying ''seed'' linearly generates numbers that generate a linear sequence on the same page, with equal cyclic steps;
* Varying ''prime'' (provided that they are odd prime numbers) generates pseudo-random that have independent random distribution.
* Note that when ''count'' is even (such as 100 by default, or 1000 in the examples above), the generated numbers (on the same page) are all odd or all even when you are varying the ''seed'' or ''prime'', unless half of the calls use an even ''seed'' and the others used an odd ''seed''. However, later invocations will still alternate odd and even numbers on output (this problem only occurs on the same page where multiple random numbers are invoked).
* On the same page, multiple invocations of this template with the same parameters will generate the same output value, so it is possible to create multiple links related to the same article.
<includeonly>
[[Category:Mathematical function templates|{{PAGENAME}}]]
</includeonly>
 
<includeonly>
[[as:সাঁচ:Rand]]
</includeonly>

Latest revision as of 00:16, 31 January 2015

Please put all metadata in documentation page Template:Rand/doc