Template:Rand/doc
This page will only parse completely when it is included in another page.
[template]documentation subpage[/template]
This template generates a pseudo-random integer between 0 and [i]count[/i]-1.
; Usage:
[list][*] <tt>{{Rand|</tt>[i]count[/i]<tt>|</tt>[i]seed[/i]<tt>|</tt>[i]prime[/i]<tt>}}</tt>
[*] All parameters are optional and have default values. They must be integers.
[*] The default [i]count[/i] is 100 (so by default, this template generates values between 0 and 99) and must be non-zero.
[*] The default [i]seed[/i] is {{#time:z}} and can be set to any other integer value (used to generate distinct values on the same page).
[*] The default [i]prime[/i] is 67 and should be a prime number above 17 (used to generate distinct values on the same page).
[/LIST]
; Examples generating numbers between 0 and 999:
[list][*] <tt>{{Rand|1000}}</tt> = [template]Rand|1000[/template]
[*] <tt>{{Rand|1000|[template]#tim e:z[/template]|67}}</tt> = [template]Rand|1000|[template]#time:z[/template]|67[/template] (same as above)
[*] <tt>{{Rand|1000|[template]#tim e:z[/template]|61}}</tt> = [template]Rand|1000|[template]#time:z[/template]|61[/template] (this and others should all be different)
[*] <tt>{{Rand|1000|6}} ;</tt> = [template]Rand|1000|6[/template]
[*] <tt>{{Rand|1000|5}} ;</tt> = [template]Rand|1000|5[/template]
[*] <tt>{{Rand|1000|4}} ;</tt> = [template]Rand|1000|4[/template]
[*] <tt>{{Rand|1000|3}} ;</tt> = [template]Rand|1000|3[/template]
[*] <tt>{{Rand|1000|2}} ;</tt> = [template]Rand|1000|2[/template]
[*] <tt>{{Rand|1000|1}} ;</tt> = [template]Rand|1000|1[/template]
[*] <tt>{{Rand|1000|0}} ;</tt> = [template]Rand|1000|0[/template]
[*] <tt>{{Rand|1000|1|17} ;}</tt> = [template]Rand|1000|0|17[/template] (varying the prime number)
[*] <tt>{{Rand|1000|1|19} ;}</tt> = [template]Rand|1000|0|19[/template]
[*] <tt>{{Rand|1000|1|23} ;}</tt> = [template]Rand|1000|0|23[/template]
[*] <tt>{{Rand|1000|1|29} ;}</tt> = [template]Rand|1000|0|29[/template]
[*] <tt>{{Rand|1000|1|31} ;}</tt> = [template]Rand|1000|0|31[/template]
[*] <tt>{{Rand|1000|1|37} ;}</tt> = [template]Rand|1000|0|37[/template]
[*] <tt>{{Rand|1000|1|41} ;}</tt> = [template]Rand|1000|0|41[/template]
[*] <tt>{{Rand|1000|1|43} ;}</tt> = [template]Rand|1000|0|43[/template]
[*] <tt>{{Rand|1000|1|47} ;}</tt> = [template]Rand|1000|0|47[/template]
[*] <tt>{{Rand|1000|1|51} ;}</tt> = [template]Rand|1000|0|51[/template]
[*] <tt>{{Rand|1000|1|53} ;}</tt> = [template]Rand|1000|0|53[/template]
[*] <tt>{{Rand|1000|1|59} ;}</tt> = [template]Rand|1000|0|59[/template]
[*] <tt>{{Rand|1000|1|61} ;}</tt> = [template]Rand|1000|0|61[/template]
[*] <tt>{{Rand|1000|1|67} ;}</tt> = [template]Rand|1000|0|67[/template]
[*] <tt>{{Rand|1000|1|71} ;}</tt> = [template]Rand|1000|0|71[/template]
[*] <tt>{{Rand|1000|1|73} ;}</tt> = [template]Rand|1000|0|73[/template]
[*] <tt>{{Rand|1000|1|79} ;}</tt> = [template]Rand|1000|0|79[/template]
[/LIST]
; Note:
[list][*] Varying [i]seed[/i] linearly generates numbers that generate a linear sequence on the same page, with equal cyclic steps;
[*] Varying [i]prime[/i] (provided that they are odd prime numbers) generates pseudo-random that have independent random distribution.
[*] Note that when [i]count[/i] 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 [i]seed[/i] or [i]prime[/i], unless half of the calls use an even [i]seed[/i] and the others used an odd [i]seed[/i]. However, later invokations 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 invokations of this template with the same parameters will generate the same ouput value, so it is possible to create multiple links related to the same article.
[/LIST]
This template generates a pseudo-random integer between 0 and [i]count[/i]-1.
; Usage:
[list][*] <tt>{{Rand|</tt>[i]count[/i]<tt>|</tt>[i]seed[/i]<tt>|</tt>[i]prime[/i]<tt>}}</tt>
[*] All parameters are optional and have default values. They must be integers.
[*] The default [i]count[/i] is 100 (so by default, this template generates values between 0 and 99) and must be non-zero.
[*] The default [i]seed[/i] is {{#time:z}} and can be set to any other integer value (used to generate distinct values on the same page).
[*] The default [i]prime[/i] is 67 and should be a prime number above 17 (used to generate distinct values on the same page).
[/LIST]
; Examples generating numbers between 0 and 999:
[list][*] <tt>{{Rand|1000}}</tt> = [template]Rand|1000[/template]
[*] <tt>{{Rand|1000|[template]#tim e:z[/template]|67}}</tt> = [template]Rand|1000|[template]#time:z[/template]|67[/template] (same as above)
[*] <tt>{{Rand|1000|[template]#tim e:z[/template]|61}}</tt> = [template]Rand|1000|[template]#time:z[/template]|61[/template] (this and others should all be different)
[*] <tt>{{Rand|1000|6}} ;</tt> = [template]Rand|1000|6[/template]
[*] <tt>{{Rand|1000|5}} ;</tt> = [template]Rand|1000|5[/template]
[*] <tt>{{Rand|1000|4}} ;</tt> = [template]Rand|1000|4[/template]
[*] <tt>{{Rand|1000|3}} ;</tt> = [template]Rand|1000|3[/template]
[*] <tt>{{Rand|1000|2}} ;</tt> = [template]Rand|1000|2[/template]
[*] <tt>{{Rand|1000|1}} ;</tt> = [template]Rand|1000|1[/template]
[*] <tt>{{Rand|1000|0}} ;</tt> = [template]Rand|1000|0[/template]
[*] <tt>{{Rand|1000|1|17} ;}</tt> = [template]Rand|1000|0|17[/template] (varying the prime number)
[*] <tt>{{Rand|1000|1|19} ;}</tt> = [template]Rand|1000|0|19[/template]
[*] <tt>{{Rand|1000|1|23} ;}</tt> = [template]Rand|1000|0|23[/template]
[*] <tt>{{Rand|1000|1|29} ;}</tt> = [template]Rand|1000|0|29[/template]
[*] <tt>{{Rand|1000|1|31} ;}</tt> = [template]Rand|1000|0|31[/template]
[*] <tt>{{Rand|1000|1|37} ;}</tt> = [template]Rand|1000|0|37[/template]
[*] <tt>{{Rand|1000|1|41} ;}</tt> = [template]Rand|1000|0|41[/template]
[*] <tt>{{Rand|1000|1|43} ;}</tt> = [template]Rand|1000|0|43[/template]
[*] <tt>{{Rand|1000|1|47} ;}</tt> = [template]Rand|1000|0|47[/template]
[*] <tt>{{Rand|1000|1|51} ;}</tt> = [template]Rand|1000|0|51[/template]
[*] <tt>{{Rand|1000|1|53} ;}</tt> = [template]Rand|1000|0|53[/template]
[*] <tt>{{Rand|1000|1|59} ;}</tt> = [template]Rand|1000|0|59[/template]
[*] <tt>{{Rand|1000|1|61} ;}</tt> = [template]Rand|1000|0|61[/template]
[*] <tt>{{Rand|1000|1|67} ;}</tt> = [template]Rand|1000|0|67[/template]
[*] <tt>{{Rand|1000|1|71} ;}</tt> = [template]Rand|1000|0|71[/template]
[*] <tt>{{Rand|1000|1|73} ;}</tt> = [template]Rand|1000|0|73[/template]
[*] <tt>{{Rand|1000|1|79} ;}</tt> = [template]Rand|1000|0|79[/template]
[/LIST]
; Note:
[list][*] Varying [i]seed[/i] linearly generates numbers that generate a linear sequence on the same page, with equal cyclic steps;
[*] Varying [i]prime[/i] (provided that they are odd prime numbers) generates pseudo-random that have independent random distribution.
[*] Note that when [i]count[/i] 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 [i]seed[/i] or [i]prime[/i], unless half of the calls use an even [i]seed[/i] and the others used an odd [i]seed[/i]. However, later invokations 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 invokations of this template with the same parameters will generate the same ouput value, so it is possible to create multiple links related to the same article.
[/LIST]
Contributors: | ,
Created by Last edited by , 10-23-2011 at 02:14 PM 0 Comments, 975 Views |
, 11-23-2008 at 08:25 PM
Tags for this Page
Similar Pages
-
Rand
By Arjan in forum TemplateComments: 0Last Post: 11-23-2008, 08:24 PM
Bookmarks