Re: Let's try this ONE more time :-)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Al Getz wrote:
> 
> Pete Lomax wrote:
> > 
> > On Mon, 05 Jul 2004 11:51:21 -0700, Al Getz <guest at RapidEuphoria.com>
> > wrote:
> > 
> > >For people that cant read English, i post this one more time:
> > And people say I need to try decaffeinated. blink)
> > 
> > 
> There were at least TWO (count em, 2> ) posts suggesting
> a method of generating 32 bit random numbers which were
> perfectly fine, and yet people were still bickering over
> what to do about generating a 32 bit rand number ??

Bickering? Suggesting alternates is normal in programming. Why do you 
think this is evidence of bickering?

There are a huge number of ways to generate a 32-bit random number. So
what's the problem if people suggest some alternatives?

> Makes me wonder about the intellegence level in this group,
> any IQ's over 20 here, or did i miss something somewhere...

Apparently so. For example, "cant" is really spelled "can't"; 
the 1-st person singular pronoun is supposed to be spelled "I" and not
"i"; and adding two random numbers does not produce a third random number.

Let's say we are trying for random numbers from 1 to 100. If we
are using two independant random number generators 'randA' and 'randB',
and use something like floor(randA(100) + randB(100)) / 2) to do this.

This seems reasonable, but consider this...

What is the probability of getting 25? Which is two random numbers adding
up to 50 then dividing by 2? Quite high, actually. We have 1+49, 2+48,
3+47, ... 49+1; which 49 out of a possible 10000 different sums.
Now how about the probability of 1? (two randoms adding up to 2). 
1+1; which is 1 out of 10000. 

Thus we have very poor distribution of numbers if we just use the
additive method. And the story is much the same for multipliction,
though the distribution curve is a different shape.

For concatenation though, its more like this...

 Formula -->  (randA(10)-1) * 10 + (randB(10)-1) + 1

The probability for 25 ('2' followed by '5') is (1/10 * 1/10) ==> 1/100.
The probability for 1 ('0' followed by '1') is (1/10 * 1/10) ==> 1/100.
Etc for all numbers in the range. A uniform probability distribution. 
 
> Take care,

Good advice, doctor.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu