1

So I get that all the built in function only return pseudo random numbers as they use the clock speed or some other hardware to get the number.

So here my idea, if I take two pseudo random numbers and bitwise them together would the result still be pseudo random or would it be closer to truly random.

I figured that if I fiddled about with the number a bit it would be less replicable, or am I getting this wrong.

On a side note why is pseudo random a problem?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Skeith
  • 2,512
  • 5
  • 35
  • 57
  • There is no such thing as "more random". – Cody Gray - on strike Apr 20 '11 at 10:51
  • possible duplicate of [Understanding "randomness"](http://stackoverflow.com/questions/3956478/understanding-randomness). Belisarius's answer here is excellent, and deserves at least *most* of those 800-some upvotes. – Cody Gray - on strike Apr 20 '11 at 10:51
  • You should definitively read the first chapter of "The Art Of Computer Programming" by Knuth. He gives an example on how he was wrong doing this kind of stuff. In the end algorithms were "less" random. Yes it is counter intuitive. – yogsototh Apr 21 '11 at 07:28

2 Answers2

7

It will not be more random, but there is a big risk that the number will be less random (less uniformly ditributed). What bitwise operator were you thinking about?

Lets assume 4-bit random numbers 0101, 1000. When OR:ed together you would get 1101. With OR there would be a clear bias towards 1111, with AND towards 0000. (75 % of getting a 1 or 0 respectively in each position)

I don't think XOR and XNOR would be biased. But also you wouldn't get any more randomness out of it (see Pavium's answer).

Moberg
  • 5,253
  • 4
  • 38
  • 54
4

Algorithms executed by computers are deterministic.

You can only generate truly random numbers if there's a non-deterministic input.

Pseudo-random numbers follow a repeating sequence. Maybe a long sequence but the repetition makes them predictable and therefore not truly random.

You can't generate truly random numbers from two pseudo-random numbers.

EDITED: to put the sentences in a more logical order.

pavium
  • 14,808
  • 4
  • 33
  • 50