To test this and see if the allegations are true, I wrote this alias to run a series of 100,000 random runs:
alias rand.count {
var %1, %2, %3, %4, %5
var %i = 1
while (%i < 100000) {
inc $+(%,$r(1,5))
inc %i
}
echo -ati2 ** 1( $+ %1 $+ ) 2( $+ %2 $+ ) 3( $+ %3 $+ ) 4( $+ %4 $+ ) 5( $+ %5 $+ )
}
Here are the results of several runs of this alias.
** 1(12458) 2(24842) 3(25015) 4(25157) 5(12527)
** 1(12876) 2(24764) 3(25271) 4(24720) 5(12368)
** 1(12422) 2(25034) 3(25186) 4(24885) 5(12472)
** 1(12600) 2(24789) 3(25104) 4(25070) 5(12436)
** 1(12632) 2(25110) 3(24968) 4(25071) 5(12218)
** 1(12517) 2(25157) 3(25078) 4(24769) 5(12478)
** 1(12599) 2(25137) 3(24835) 4(24956) 5(12472)
** 1(12457) 2(25135) 3(25054) 4(24914) 5(12439)
** 1(12666) 2(25126) 3(25196) 4(24663) 5(12348)
** 1(12630) 2(25098) 3(24893) 4(24997) 5(12381)
From this, we can determine that the first and last DO show up half the number of times as the others. 2-4 are quite evenly distributed. That means that if you wanted to derive a "more truly random number", take $rand(1-(N-1), counting N as a 1. So if I need a random number from 1 to 3, I can use something $rr(1,3) - like this:
alias rr {
var %n = $rand($1,$calc($2 + 1))
if (%n == $calc($2 + 1)) return $1
return %n
)
Substituting $rr for $r in the above alias uses the new RealRand alias and returns the following:
** 1(19939) 2(19977) 3(19938) 4(20143) 5(20002)
** 1(19971) 2(19956) 3(20202) 4(20162) 5(19708)
** 1(19813) 2(20021) 3(20046) 4(19967) 5(20152)
** 1(20190) 2(20199) 3(19999) 4(19823) 5(19788)
** 1(19808) 2(20136) 3(19971) 4(19991) 5(20093)
** 1(20027) 2(20198) 3(19994) 4(19891) 5(19889)
** 1(19928) 2(19954) 3(20049) 4(20106) 5(19962)
** 1(20020) 2(20014) 3(20107) 4(19976) 5(19882)
** 1(19998) 2(20161) 3(19927) 4(19971) 5(19942)
** 1(20078) 2(19899) 3(19991) 4(20139) 5(19892)