# Question on Randomness

**URL:** <https://boards.straightdope.com/t/question-on-randomness/492535>\
**Category:** Factual Questions\
**Created:** [April 9, 2009, 5:44pm UTC](https://boards.straightdope.com/t/question-on-randomness/492535 "2009-04-09T17:44:22Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![tdn](https://avatars.discourse-cdn.com/v4/letter/t/94ad74/32.png) [@tdn](https://boards.straightdope.com/u/tdn)\
**Post date:** [April 10, 2009, 8:59pm UTC](https://boards.straightdope.com/t/question-on-randomness/492535/21 "2009-04-10T20:59:30Z")

</div>

> [@ultrafilter](#):
>
> I’m game for this.

Me too.

I propose this:

Make three lists of 100 digits each.

The first one will be computer generated.

The second will be hand selected by you, so as to appear as random as you can make it.

For the 3rd, go to your local gaming store and pick up a 10-sided die. Roll it 100 times and record the results.

Then see if we can determine which list is which.

---

<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:** [April 10, 2009, 9:33pm UTC](https://boards.straightdope.com/t/question-on-randomness/492535/22 "2009-04-10T21:33:18Z")

</div>

Unless the OP is writing his own arithmetic-based prng, the computer and dice generated lists will be indistinguishable unless they’re very long. Let’s stick with the human and computer generated lists here.

---

<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:** [April 10, 2009, 9:51pm UTC](https://boards.straightdope.com/t/question-on-randomness/492535/23 "2009-04-10T21:51:30Z")

</div>

Quoth **Pleonast** :

> [@](#):
>
> I don’t doubt that any system default rand function is poor, but one has to be careful about how it’s tested. In the case given here, there’s a good way and a poor way of testing. (I’m not saying you did it poorly, but I don’t want other less experienced readers to do poor testing.)
> 
> The poor way is something like
> 
> ```
> r = (rand()%47)+1;
> 
> ```
> 
> and the good way is something like this
> 
> ```
> r = ceil((rand()/(RAND_MAX+1.0))*47.0);
> 
> ```
> 
> I’m assuming the rand() function is the typical function that returns an integer between 0 and RAND\_MAX, inclusively. The poor way takes the modulus by 47 (that is, returns the remainder after dividing through by 47). The problem is that RAND\_MAX is not a multiple 47; it’s usually one less than a power of two. Imagine it was 63–do you see the problem? 48-63 get mapped to 0-16, and so the lower numbers get hit more often.
> 
> The good way avoids this by doing the extra work to properly scale the random integer.

This isn’t really any better, since RAND\_MAX still isn’t a multiple of 47. Some numbers will still get the extras; they’ll just be spread out across the whole range instead of clustered at the bottom. A truly uniform method will have to have a non-fixed number of times it calls the rand function, so that (using your RAND\_MAX = 63 example) if you get a result of 1 through 47 you keep it, but if you get a 48 or higher, you roll the dice again.

---

<div class="post-metadata">

**Author:** ![flonks](https://avatars.discourse-cdn.com/v4/letter/f/3ab097/32.png) [@flonks](https://boards.straightdope.com/u/flonks)\
**Post date:** [April 11, 2009, 3:05pm UTC](https://boards.straightdope.com/t/question-on-randomness/492535/24 "2009-04-11T15:05:56Z")

</div>

I would suggest wiring your computer to [this device](http://farm1.static.flickr.com/130/331577131_ed2b83d040.jpg?v=0) as well as a webcam and then connect together an OCR (optical character recognition) software and a small python script in order to recognize the numbers coming out.

That should give you “real” randomness, not just pseudo random numbers

[Previous page](https://boards.straightdope.com/t/question-on-randomness/492535.md?page=1)
