uniform random distribution
From: aegis (aegis_at_mad.scientist.com)
Date: 01/30/05
- Next message: Carramba: "compiling quistion"
- Previous message: Michael Mair: "Re: array riddle in c"
- Next in thread: Rouben Rostamian: "Re: uniform random distribution"
- Reply: Rouben Rostamian: "Re: uniform random distribution"
- Reply: Michael Mair: "Re: uniform random distribution"
- Reply: Martin Ambuhl: "Re: uniform random distribution"
- Maybe reply: CBFalconer: "Re: uniform random distribution"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Jan 2005 13:18:11 -0800
is there any trickery that can be done
with rand() so that it generates a uniformly
distributed sequence?
Suppose that I want any thing in the range
m..n (inclusive) to be generated such that
I never have a recurrence of a number.
I could build a table I suppose as I call
rand and any number in that table already
can be ignored. So I can sit and call rand
until I get the desired number that is not yet
in the list.
So if I want (inclusive) 0..3
then imagine rand() % (3 + 1) working as desired.
I consider the use of a table to keep track to be
a pretty idiotic approach though. Anyone have
another way of doing it, up their sleeve?
-- aegis
- Next message: Carramba: "compiling quistion"
- Previous message: Michael Mair: "Re: array riddle in c"
- Next in thread: Rouben Rostamian: "Re: uniform random distribution"
- Reply: Rouben Rostamian: "Re: uniform random distribution"
- Reply: Michael Mair: "Re: uniform random distribution"
- Reply: Martin Ambuhl: "Re: uniform random distribution"
- Maybe reply: CBFalconer: "Re: uniform random distribution"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|