Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 23 April 2012 - 06:10 PM
Posted 23 April 2012 - 07:08 PM
Posted 23 April 2012 - 07:37 PM
Posted 23 April 2012 - 07:51 PM
“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”
Posted 23 April 2012 - 08:35 PM
Posted 23 April 2012 - 10:03 PM
Posted 23 April 2012 - 11:55 PM
No, XOR is a binary operation and has the property that a xor a = 0, so repeatedly XORing a pair of numbers together won't produce a very interesting sequence!So I can XOR two random numbers together and get a number at least as random as the less random one? And I can keep doing that as much as I want to get more and more random numbers?
It may seem so but in fact, it's actually very fast because when you have a 2KB internal state, you generally produce 2KB of random data at each step of the algorithm (in non-cryptographic generators, that is), so the total cost is fully amortized. The idea is that the bigger the state, the more entropy you have available to play with, shuffle around, etc... which, literally put, makes it harder to screw up. It's just simpler to use big states.And 2KB?? Seriously? Isn't that a bit extreme and would it not be very slow?
This is actually debatable, if you stick to small words (say, an 8-bit byte) and work on arrays of those words then you are able to mix logical (XOR, NOT, etc...) and arithmetic (addition, subtraction, ...) operations in a much less predictable way and maximize diffusion. Of course you can also use both methods, but it's important to keep it simple.Use arithmetic (in particular, multiplication) with numbers as large as possible.
“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”
Posted 24 April 2012 - 12:26 AM
Posted 24 April 2012 - 01:30 AM
Posted 24 April 2012 - 06:32 AM
No, XOR is a binary operation and has the property that a xor a = 0, so repeatedly XORing a pair of numbers together won't produce a very interesting sequence!So I can XOR two random numbers together and get a number at least as random as the less random one? And I can keep doing that as much as I want to get more and more random numbers?
And same for addition, if you keep doing it then there will be correlation between successive values generated which means the sequence won't be very random either.
Example: say A = 6 and B = 9. So A + B = 15. Without knowing A and B, A + B would seem random. But if you keep adding B, you get 15, 24, 33, 42, 51, etc... which clearly is not random.
Posted 24 April 2012 - 06:36 AM
Posted 24 April 2012 - 07:27 AM
Posted 24 April 2012 - 09:34 AM
Posted 24 April 2012 - 12:31 PM
Posted 24 April 2012 - 03:08 PM
I suppose it would be faster in a sense but it's not practical, imagine you need trillions of random numbers for a very long-running simulation (this is not uncommon), you aren't gonna be able to precalculate them all at the beginning. And the performance gain is probably not worth the increased memory use.Alright so it's faster to generate all of the random numbers at the start and then iterate through them one by one?
I'm not familiar with Hashes at all - I'll check my book and google for more info, of course.
No you don't need to do this. You just call the PRNG each time you need a pseudorandom number, it will give you one quickly. Remember that while memory probably abounds on your laptops and desktops, embedded devices also need some form of pseudorandom number generator, and it probably can't afford kilobytes of memory. Pseudorandom theory has improved enough to let us generate a virtual infinity of very high quality pseudorandom numbers very efficiently on a computer in O(1) memory, we should use this to our advantage.So I could do this with two or three tables of different lengths and XOR the results and get a lot of randomness right?
And it would still be fast?
Or should I just create one really, really big table at the start?
“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”
Posted 24 April 2012 - 10:50 PM
Posted 24 April 2012 - 11:20 PM
No because then you'd have the sequence:Would it typically be a bad idea to XOR x{n} with x{n-1} or x{n-2}? Then I won't need to generate more numbers but since they have something in common that's probably bad right?
Yeah the math around pseudorandom numbers is pretty tough but much of it can be understood intuitively, and it's not like you need to know the theory to enjoy playing around with algorithmsLooks like I don't have the math skills to grasp much of the theory, though. That's a shame.
“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”
Posted 25 April 2012 - 02:10 AM
Can anyone link me to some pseudo-random papers or websites?
Posted 28 April 2012 - 05:51 PM
Edited by Expert Novice, 28 April 2012 - 07:32 PM.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.