[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to generate random negative numbers



On Wednesday 26 August 2009 23:19:18 Celejar wrote:
> On Wed, 12 Aug 2009 15:26:06 -0500
> "Boyd Stephen Smith Jr." <bss@iguanasuicide.net> wrote:
> > $RANDOM gives a random number.  It has a relatively large range, I think
> > 0-32K maybe even larger.
>
> ...
>
> > Examples:
> > echo $((RANDOM % 6 + 1)) # Rolls a "normal" die[1].
>
> ...
>
> > [1] But not a fair one.  If the $RANDOM function is completely random, so
> > that over the "long tail" all values show up with the same frequency, the
> > die will be slightly biased low.
>
> Do you mean that it will be biased low since the range (presumably)
> doesn't end on a number of the form 6n-1, or something else?

Yes.  That's all I meant.  ISTR some roguelikes use code to correct for this 
low bias.
-- 
Boyd Stephen Smith Jr.           	 ,= ,-_-. =.
bss@iguanasuicide.net            	((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy 	 `-'(. .)`-'
http://iguanasuicide.net/        	     \_/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: