How to do an equitable random ?
rand gives [0-1], or [0-1[ or ]0-1] or [0-1[ ?
i think its [0-1]
( 6] = 6 include, 6[ = 6 exclude )
Now if I want a rand that returns a int
between 0 and x-1
ex : x=5
i want 0-1-2-3- or 4
i= will be the array indice.
what the correct formule ?
i=x*rand ?
if i do this, i my experience was good, i could get x, so you can have an ArrayOutOfBound
i=(x-1)*rand ?
same, you only get i=x-1 if rand gives 1 => 1/100 chance ?
because i=int/rand=flex and i dont know how to trunc/assign correctly...
[This message has been edited by TCNF_Merfolk (edited November 10, 2002).]
rand gives [0-1], or [0-1[ or ]0-1] or [0-1[ ?
i think its [0-1]
( 6] = 6 include, 6[ = 6 exclude )
Now if I want a rand that returns a int
between 0 and x-1
ex : x=5
i want 0-1-2-3- or 4
i= will be the array indice.
what the correct formule ?
i=x*rand ?
if i do this, i my experience was good, i could get x, so you can have an ArrayOutOfBound
i=(x-1)*rand ?
same, you only get i=x-1 if rand gives 1 => 1/100 chance ?
because i=int/rand=flex and i dont know how to trunc/assign correctly...
[This message has been edited by TCNF_Merfolk (edited November 10, 2002).]