How do I define a good pseudo-random number generator?
should be uniform distribution.
Interesting, I could define a good random number generator, but what can be good about a pseudo-random number generator?
I need one to complete my shuffling algorithm (the native pseudo_random number generator provided by my C implementation is deficient)
Couldnt you try to do something with time() ?
Here are 10000 random numbers for ya: http://www.agner.org/random/10000ran.zip
Maybe I could easily fix it; the problem is that the number it yields are too small (between 0 and 32767) :(
ah, what range are you looking for?
I need 50 million random numbers
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
Would be great if it has an arbitrary range
Do you need your numbers to range from 0 to 50mil or do you want a series of 50m numbers?
range from 0 to 2^32 - 1
you could use the modulus operator to get them in a specific range
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?
I want to shuffle huge lists of data.
In an array?
Maybe your problem will be memory?
nah my problem is the default RNG is too tiny - has a range of 0 to 32767
random * random * random * random would dramitically increase the range ;)
easy fix! thanks
Don't think that will work too well, for instance the lowest number you'll get after 32767 is 32767*2, assuming integers
check the distribution before you use it, i'm not sure it's completely usable...
I believe there is also another library function called random() instead of rand() that returns "long" values
yeah I think C++ has better random() functions.... one more reason for me to switch to C++
Join our real-time social learning platform and learn together with your friends!