Ask your own question, for FREE!
Mathematics 7 Online
OpenStudy (anonymous):

How do I define a good pseudo-random number generator?

OpenStudy (anonymous):

should be uniform distribution.

OpenStudy (anonymous):

Interesting, I could define a good random number generator, but what can be good about a pseudo-random number generator?

OpenStudy (anonymous):

I need one to complete my shuffling algorithm (the native pseudo_random number generator provided by my C implementation is deficient)

OpenStudy (anonymous):

Couldnt you try to do something with time() ?

OpenStudy (anonymous):

Here are 10000 random numbers for ya: http://www.agner.org/random/10000ran.zip

OpenStudy (anonymous):

Maybe I could easily fix it; the problem is that the number it yields are too small (between 0 and 32767) :(

OpenStudy (anonymous):

ah, what range are you looking for?

OpenStudy (anonymous):

I need 50 million random numbers

OpenStudy (anonymous):

All pseudo-random generators have a period, which is why it needs to be 'seeded' with something like time(). Look at this list. http://en.wikipedia.org/wiki/List_of_pseudorandom_number_generators

OpenStudy (anonymous):

Would be great if it has an arbitrary range

OpenStudy (anonymous):

Do you need your numbers to range from 0 to 50mil or do you want a series of 50m numbers?

OpenStudy (anonymous):

range from 0 to 2^32 - 1

OpenStudy (anonymous):

you could use the modulus operator to get them in a specific range

OpenStudy (anonymous):

I doubt that after 50 million times, you're still going to have a 'uniform' distribution. More like a 'normal' distribution, but hey you're shuffling cards?

OpenStudy (anonymous):

I want to shuffle huge lists of data.

OpenStudy (anonymous):

In an array?

OpenStudy (anonymous):

Maybe your problem will be memory?

OpenStudy (anonymous):

nah my problem is the default RNG is too tiny - has a range of 0 to 32767

OpenStudy (anonymous):

http://www.azillionmonkeys.com/qed/random.html

OpenStudy (anonymous):

random * random * random * random would dramitically increase the range ;)

OpenStudy (anonymous):

easy fix! thanks

OpenStudy (anonymous):

Don't think that will work too well, for instance the lowest number you'll get after 32767 is 32767*2, assuming integers

OpenStudy (anonymous):

check the distribution before you use it, i'm not sure it's completely usable...

OpenStudy (anonymous):

I believe there is also another library function called random() instead of rand() that returns "long" values

OpenStudy (anonymous):

yeah I think C++ has better random() functions.... one more reason for me to switch to C++

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!