# What's the difference between a random number and a pseudo-random number?

**URL:** <https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004>\
**Category:** Factual Questions\
**Created:** [December 4, 2011, 4:00am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004 "2011-12-04T04:00:32Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Leo\_Bloom](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/leo_bloom/32/10377_2.png) [@Leo\_Bloom](https://boards.straightdope.com/u/Leo_Bloom)\
**Post date:** [December 6, 2011, 2:15am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/41 "2011-12-06T02:15:28Z")

</div>

> [@panamajack](#):
>
> May as well bring up the [best Amazon book review ever](http://www.amazon.com/Million-Random-Digits-Normal-Deviates/dp/0833030477).

Wonderful 27 pages of witty comments.

Who uses hand transferred (ie from hard copy) to software input? Shouldn’t this data be released electronically?

Also, what’s a normal deviant? ::straight line:: 1) the word is nicely oxymoronic, and 2) I consider myself a normal deviant (just ask my shrink).

Seriously, in random-number theory, what’s a normal deviant?

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [December 6, 2011, 2:23am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/42 "2011-12-06T02:23:07Z")

</div>

> [@Chronos](#):
>
> And the reason you have two different ones is that your entropy pool is a valuable resource, one that you don’t want to just waste on something trivial like a game.

There’s nothing _trivial_ about games. :mad:

> [@Leo\_Bloom](#):
>
> Wonderful 27 pages of witty comments.
> 
> Who uses hand transferred (ie from hard copy) to software input? Shouldn’t this data be released electronically?

That book was from long before everybody had a computer (and therefore a convenient source of pseudorandom numbers) at their fingertips. People would indeed use it for various pencil-and-paper calculations that required a random input or sequence. Or on smaller computers that didn’t have PRNG hardware. It’s only useful today as a historical relic.

> [@](#):
>
> Also, what’s a normal deviant? ::straight line:: 1) the word is nicely oxymoronic, and 2) I consider myself a normal deviant (just ask my shrink).

Normal devi_ate_, not deviant. It’s just a a number between 0 and 1. They are used in statistics and sometimes you want a random number between 0 and 1 to test your statistical algorithms.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [December 6, 2011, 2:27am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/43 "2011-12-06T02:27:10Z")

</div>

> [@friedo](#):
>
> That book was from long before everybody had a computer (and therefore a convenient source of pseudorandom numbers) at their fingertips. People would indeed use it for various pencil-and-paper calculations that required a random input or sequence. Or on smaller computers that didn’t have PRNG hardware. It’s only useful today as a historical relic.

Seriously. My crappy laptop can reproduce the entire contents of that book in about a tenth of a second.

R code:

```auto

library(matlab)
tic()
x <- rnorm(1e5)
y <- sample(0:9, 1e6, replace = TRUE)
toc()

```

---

<div class="post-metadata">

**Author:** ![JWT\_Kottekoe](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@JWT\_Kottekoe](https://boards.straightdope.com/u/JWT_Kottekoe)\
**Post date:** [December 6, 2011, 2:31am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/44 "2011-12-06T02:31:31Z")

</div>

> [@friedo](#):
>
> Normal devi_ate_, not deviant. It’s just a a number between 0 and 1

Not quite, a normal deviate is a sample from a random variable with a normal distribution (the standard bell-shaped curve, otherwise known as a Gaussian distribution). A normal deviate can take any value between negative and positive infinity. A standard normal deviate comes from a distribution with a mean of zero and a variance of 1.

---

<div class="post-metadata">

**Author:** ![constanze](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@constanze](https://boards.straightdope.com/u/constanze)\
**Post date:** [December 6, 2011, 8:41am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/45 "2011-12-06T08:41:07Z")

</div>

Also to remember: while crytography etc. needs truly random numbers, and others (as explained already) need pseudo-random for repeating, humans also don’t want true randomness.

What humans perceive as randomness is really randmoness with a filter removing obvious sequences - sequences which are obvious to humans though they have been produced by truly random means. We’ve had several threads on this regarding music players in “shuffle” mode - companies first used a normal random function, but then people complained that two Beatle songs were played right after another, or song Nr. 5 after song 6, so the random function must be broken.  
Now the software keeps track of the last five titles or so to avoid repetition (making everything more complicated than a simple RND command), and giving humans the illusion of true randomness.

Another example: if you throw 6 dice and get 1,2,3,4,5,6 in a row, you’d claim it’s not random because it’s ordered. But unless the dice were tampered with, and if you used a true random means of throwing, then the production was random, and therefore the result, too. And you can’t predict the next throw from this, either. Yet humans assign a meaning to this particular sequence out of all possible ones and label it as ordered.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [December 6, 2011, 5:42pm UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/46 "2011-12-06T17:42:28Z")

</div>

> [@](#):
>
> And you can’t predict the next throw from this, either.

You can too! I’ll bet the next roll will be 7.

---

<div class="post-metadata">

**Author:** ![septimus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/septimus/32/410_2.png) [@septimus](https://boards.straightdope.com/u/septimus)\
**Post date:** [December 6, 2011, 9:08pm UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/47 "2011-12-06T21:08:59Z")

</div>

> [@tellyworth](#):
>
> [This one](http://www.cigital.com/papers/download/developer_gambling.php) springs to mind as a memorable example.

Wow. I’ve been around the block enough to know poor programming is almost more the rule than the exception, even when real money, lives, or important secrets are at stake, but that shuffle routine is remarkable!

… then again, I suppose we can’t rule out the possibility that the coder was a very clever guy who ended up making a lot of money at the PlanetPoker Internet cardroom. 😛

---

<div class="post-metadata">

**Author:** ![BigT](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bigt/32/12044_2.png) [@BigT](https://boards.straightdope.com/u/BigT)\
**Post date:** [December 6, 2011, 9:56pm UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/48 "2011-12-06T21:56:40Z")

</div>

> [@friedo](#):
>
> There’s nothing _trivial_ about games. :mad:

Particularly when real money is involved.

---

<div class="post-metadata">

**Author:** ![Shalmanese](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Shalmanese](https://boards.straightdope.com/u/Shalmanese)\
**Post date:** [December 7, 2011, 1:23am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/49 "2011-12-07T01:23:17Z")

</div>

> [@Digital\_is\_the\_new\_Analog](#):
>
> Another angle on ‘randomness’.. At my old company, we were evaluating a security piece of one of our processors. It had a security key burned into a series of fuses. The vendor was claiming the key was actually random..and unique.
> 
> A truly random process can’t guarantee uniqueness\*. In security, the knowledge that there are no duplicates can make cracking efforts easier.
> 
> \*Unless they screened out the duplicates, which would leave the process random, but the results not.  
> -D/a

Yes you can. Imagine you assign a different numerical value to every card in a deck and then you shuffle the deck randomly. The sequence of cards coming off the deck will be truly random but no card will have the same value as any other card.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [December 7, 2011, 1:40am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/50 "2011-12-07T01:40:51Z")

</div>

> [@Shalmanese](#):
>
> Yes you can. Imagine you assign a different numerical value to every card in a deck and then you shuffle the deck randomly. The sequence of cards coming off the deck will be truly random but no card will have the same value as any other card.

And if you’ve seen the first k cards, you have information about what the (k + 1)st card says that you wouldn’t have otherwise. If the cards are independent, you get no information, and that’s more secure.

---

<div class="post-metadata">

**Author:** ![cmyk](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cmyk/32/3353_2.png) [@cmyk](https://boards.straightdope.com/u/cmyk)\
**Post date:** [December 7, 2011, 2:00am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/51 "2011-12-07T02:00:04Z")

</div>

> [@Chronos](#):
>
> You can too! I’ll bet the next roll will be 7.

Crap.

---

<div class="post-metadata">

**Author:** ![Hari\_Seldon](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/hari_seldon/32/5173_2.png) [@Hari\_Seldon](https://boards.straightdope.com/u/Hari_Seldon)\
**Post date:** [December 7, 2011, 2:21am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/52 "2011-12-07T02:21:45Z")

</div>

> [@ultrafilter](#):
>
> No public key cryptography = no ecommerce. What’s impractical about that?

I don’t think public key cryptography depends in any way on random numbers. You find a pair of 500 digit primes and multiply them and choose an exponent and you are in business.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [December 7, 2011, 3:51am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/53 "2011-12-07T03:51:23Z")

</div>

> [@Hari\_Seldon](#):
>
> I don’t think public key cryptography depends in any way on random numbers. You find a pair of 500 digit primes and multiply them and choose an exponent and you are in business.

People are talking pretty seriously about deprecating RSA in favor of elliptic curve algorithms. Apparently factorization is a little too close to practical these days.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [December 7, 2011, 3:58am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/54 "2011-12-07T03:58:20Z")

</div>

> [@](#):
>
> I don’t think public key cryptography depends in any way on random numbers. You find a pair of 500 digit primes and multiply them and choose an exponent and you are in business.

And how do you pick those two primes? If anyone knows what method you used to pick your primes, they can figure out what the primes were, and hence your private key. Unless, of course, you have a good, truly random, way of picking them.

---

<div class="post-metadata">

**Author:** ![Francis\_Vaughan](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/francis_vaughan/32/3093_2.png) [@Francis\_Vaughan](https://boards.straightdope.com/u/Francis_Vaughan)\
**Post date:** [December 7, 2011, 4:01am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/55 "2011-12-07T04:01:26Z")

</div>

> [@](#):
>
> You find a pair of 500 digit primes

How random is your algorithm for finding those two primes? Or put another way, how much entropy is in your choice? If there is a common algorithm for finding and then choosing primes I need to know that it doesn’t contain issues that result in the sequence of primes actually used by people creating keys doesn’t produce a limited search space of primes, thus making brute force attack possible. Thus the choice of primes must itself be true random. The key generation is only as good as the random input. Primes are just an implementation tactic used to make it hard to find.

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [December 7, 2011, 4:21am UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/56 "2011-12-07T04:21:00Z")

</div>

> [@Francis\_Vaughan](#):
>
> How random is your algorithm for finding those two primes? Or put another way, how much entropy is in your choice? If there is a common algorithm for finding and then choosing primes I need to know that it doesn’t contain issues that result in the sequence of primes actually used by people creating keys doesn’t produce a limited search space of primes, thus making brute force attack possible. Thus the choice of primes must itself be true random. The key generation is only as good as the random input. Primes are just an implementation tactic used to make it hard to find.

In any case, most public-key systems are used just for exchanging symmetric keys. Which are really big, hopefully unpredictable numbers.

(This is because symmetric cryptographic algorithms are a lot faster than asymmetric ones, so you don’t want to encrypt large amounts of data using the public-key algorithm.)

---

<div class="post-metadata">

**Author:** ![Shalmanese](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Shalmanese](https://boards.straightdope.com/u/Shalmanese)\
**Post date:** [December 7, 2011, 10:54pm UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/57 "2011-12-07T22:54:29Z")

</div>

> [@ultrafilter](#):
>
> And if you’ve seen the first k cards, you have information about what the (k + 1)st card says that you wouldn’t have otherwise. If the cards are independent, you get no information, and that’s more secure.

But that comes from the guarantee of uniqueness, not any algorithm that fulfills that guarantee. Also, the amount of information gained is proportionate to the ratio of k to total deck size. An easy way to mitigate this risk to just to make the deck size many orders of magnitude larger.

---

<div class="post-metadata">

**Author:** ![Frylock](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@Frylock](https://boards.straightdope.com/u/Frylock)\
**Post date:** [December 7, 2011, 11:00pm UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/58 "2011-12-07T23:00:10Z")

</div>

> [@panamajack](#):
>
> A sequence of pseudo-random numbers
> 
> 1. will repeat eventually.
> 2. can always be predicted based on the current ‘state’ (i.e. seed).

Is repetition part of the definition of pseudo-randomness? Could there not be a pseudo-random number which never repeats?

---

<div class="post-metadata">

**Author:** ![leahcim](https://avatars.discourse-cdn.com/v4/letter/l/b4bc9f/32.png) [@leahcim](https://boards.straightdope.com/u/leahcim)\
**Post date:** [December 7, 2011, 11:06pm UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/59 "2011-12-07T23:06:55Z")

</div>

> [@Frylock](#):
>
> Is repetition part of the definition of pseudo-randomness? Could there not be a pseudo-random number which never repeats?

I don’t know that it is part of the _definition_ of pseudo randomness, but any PRNG that operates on a real computer must repeat, simply because there are only a finite number of states for it to be in after each call. The best it can do is go through every possible state, but after that it _has_ to enter a state that it has already been in.

---

<div class="post-metadata">

**Author:** ![tellyworth](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tellyworth](https://boards.straightdope.com/u/tellyworth)\
**Post date:** [December 7, 2011, 11:07pm UTC](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004/60 "2011-12-07T23:07:58Z")

</div>

> [@Frylock](#):
>
> Is repetition part of the definition of pseudo-randomness? Could there not be a pseudo-random number which never repeats?

Here’s a paper describing an [aperiodic PRNG](http://www.crm.umontreal.ca/pub/Rapports/2600-2699/2624.pdf). I’m not sure such a thing is of much practical use though.

[Previous page](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004.md?page=2)

[Next page](https://boards.straightdope.com/t/whats-the-difference-between-a-random-number-and-a-pseudo-random-number/605004.md?page=4)
