Quantcast
Channel: Understanding "randomness" - Stack Overflow
Viewing all articles
Browse latest Browse all 29

Answer by PachydermPuncher for Understanding "randomness"

$
0
0

The concept you're looking for is "entropy," the "degree" of disorder of a stringof bits. The idea is easiest to understand in terms of the concept of "maximum entropy".

An approximate definition of a string of bits with maximum entropy is that it cannot be expressed exactly in terms of a shorter string of bits (ie. using some algorithm toexpand the smaller string back to the original string).

The relevance of maximum entropy to randomness stems from the fact thatif you pick a number "at random", you will almost certainly pick a numberwhose bit string is close to having maximum entropy, that is, it can't be compressed.This is our best understanding of what characterizes a "random" number.

So, if you want to make a random number out of two random samples which is "twice" asrandom, you'd concatenate the two bit strings together. Practically, you'd juststuff the samples into the high and low halves of a double length word.

On a more practical note, if you find yourself saddled with a crappy rand(), it cansometimes help to xor a couple of samples together --- although, if its truly broken eventhat procedure won't help.


Viewing all articles
Browse latest Browse all 29

Trending Articles