Random and whrandom

Will Ware wware at world.std.com
Wed Jan 24 05:51:54 EST 2001


cpsoct at my-deja.com wrote:
> but to get back to my original question. I should import random and not
> whrandom?

Yup. Just import random.

> But then i notice that seed is in whrandom?

random import whrandom, so you don't have to.

> Hmmm. so i need to import both?

Nope, just import random.

> And why are there 3 seed values? In C, there was just one.

There are three separate C-style random number generators whose outputs
are summed (fmod one) to produce the output. The result is a much better
random number, in my experience. When using C's rand() function, I have
often found patterns cropping up in what I was doing, where I had hoped
that the use of a random number generator would prevent patterns from
appearing. The whole idea is that it will behave the way real random
numbers would behave. Python's random.random() comes much closer to this
than C's rand().

If you just import random and use it normally, you'll never directly
deal with the fact that there are three separate seeds.

> and, what then is rand? id that depreciated?

I don't remember about rand. I frequently use random.random() and
random.choice(). There are also a bunch of interesting functions in
random that pertain to random variables with various interesting
probability distributions. I probably know enough probability theory
to use these correctly, but an occasion to do so hasn't arisen yet.

-- 
import string,time,os;print string.join((lambda x:x[:10]+x[8:])(map(
lambda x:string.center("*"*(lambda x:((x<24) ### Seasons Greetings, Will Ware
*(x-3))+3)(x),24),range(1,28, 2))),"\n") ################ wware at world.std.com



More information about the Python-list mailing list