46

Are you aware of, or have you devised, any practical, simple-to-learn "in-head" algorithms that let humans generate (somewhat "true") random numbers? By "in-head" I mean.. preferably without any external tools or devices. Also, a high output (many random numbers per minute) is desirable.

Asked this on SO but it didn't get much interest. Maybe this is better suited for programmers.

Aaron Hall
  • 5,895
  • 4
  • 25
  • 47
Magnus Wolffelt
  • 2,373
  • 2
  • 20
  • 23
  • 7
    @S.Lott I don't think it's absurd at all. Unpractical? Why, of course. Absurd? Certainly not. And even if it was, absurdity can pave the way for new, useful thoughts. – biziclop Feb 18 '11 at 11:28
  • 21
    9....9....9....9 - You can't prove its not random. –  Feb 18 '11 at 11:41
  • 1
    http://search.dilbert.com/comic/Random%20Number%20Generator, http://xkcd.com/221/ – Paul Butcher Feb 18 '11 at 11:42
  • http://en.wikipedia.org/wiki/17_(number) 17 is the least-random number. Everyone knows this. That's why "random" is absurd. Just avoid 17. – S.Lott Feb 18 '11 at 11:53
  • 1
    there are a few games where a good strategy might involve a random element but which don't allow a physical method to e.g. dice – jk. Feb 18 '11 at 12:51
  • 13
    S.Lott: The idea of a easzy to calculate pseudo-random number generator is not absurd at all. I think the OP wants a way to avoid the human bias here.... – Jens Feb 18 '11 at 12:55
  • 8
    I find it funny (and at the same time slightly depressing) how many people seem to appreciate an argument of ignorance. "I can't imagine it, therefore it cannot exist", or answers that are completely missing the point. – biziclop Feb 18 '11 at 12:58
  • @Jens: "easzy to calculate pseudo-random number generator". Dice seem easier and actually random. Why mess with http://en.wikipedia.org/wiki/Linear_congruential_generator when dice are cheap, reliable and simple? – S.Lott Feb 18 '11 at 13:12
  • @biziclop: "therefore it cannot exist"? Are you saying that "absurd" is the same as "can't exist"? Or are you responding to some other comment? – S.Lott Feb 18 '11 at 13:14
  • @Magnus What is the range of the numbers? – Amir Rezaei Feb 18 '11 at 13:15
  • 1
    @S.Lott Some other comment. Absurd, what's absurd? It is absurd as a practical idea of generating random numbers, but as a means of exploring how the human brain works it isn't even unusual. Although I agree it has little to do with programming, but at least we know how a PRNG works. – biziclop Feb 18 '11 at 13:19
  • @Amir preferrably arbitrary.. but I mean, if you use base 10 and have a good output of 0-9 numbers, you can just build larger ranges from from digits I suppose. – Magnus Wolffelt Feb 18 '11 at 14:06
  • I agree with @SLott, this question has very little value, real or perceived. I find it surprising that programmers would upvote this nonsense. Random numbers cannot be effectively generated "in-head." If a computer doesn't have a build in PR generation chip then it uses clock cycles and a timer to generate random bits. You can't duplicate that with your mind. Oh, [obligatory xkcd comic](http://xkcd.com/221/). – Josh K Feb 18 '11 at 17:16
  • 3
    @S.Lott I’m appalled by your un-inquisitive, unimaginative, luddite attitude (and even more appalled by the fact that other people apparently agree). I would find this algorithm *tremendously* useful. For example, I’m a tutor (teaching assistant) and I would really have needed such an algorithm to pick which students have to present their solutions on the blackboard. Do *you* always have dice on your person? Well, I don’t. And yes, other solutions exist but why not try to make do with what you have at hand? – Konrad Rudolph Feb 18 '11 at 20:14
  • @Konrad Rudolph: "un-inquisitive, unimaginative, luddite attitude". All from recognizing that the human mind is biased and any pseudo-random algorithm that was "simple enough" to execute mentally wouldn't be very random? Dice are cheap. Biases are an expensive set of mental problems we all share. It's really good in my opinion to see the bias that's there rather than pretend it doesn't exist. I'll buy you dice, if it helps. – S.Lott Feb 18 '11 at 20:18
  • 2
    @S.Lott “All from recognizing …?” No. From your using the first available obstacle as a cheap excuse not only to give up your personal quest for an answer (which is OK but still unexpected from a programmer), but also to ridicule the very idea and call the concept “useless” (which it isn’t, but even if it were, that would be completely besides the point) and an “absurdity”. If anything here is absurd then it’s your hysterical reaction. Quite frankly, I find your comment more than just a tad insulting. – Konrad Rudolph Feb 18 '11 at 20:21
  • @Konrad Rudolph: "absurd" is insulting? I'm shocked. But I apologize for insulting you in some way. What's a better word for something that can't exist? Contradiction? Oxymoron? The idea of "random" and "biased, limited human capabilities" confuses me endlessly. Perhaps I spent too long working with actuaries. Perhaps you can edit the question so that it doesn't involve the logical contraction of "biased human intellect" and "random". – S.Lott Feb 18 '11 at 20:27
  • @S.Lott Well, once a bias is known it can in principle be eliminated using statistics so I really fail to see the contradiction; difficulties, yes. Fundamental contradiction? No. But what I find insulting is your crass dismissal of the OP’s idea. Basically, there’s some chap thinking about a problem which intrigues him and your reaction, without explanation, without assessment of the OP’s prior knowledge of the subject matter, is to tell him that his idea is an “award-winning absurdity”. – Konrad Rudolph Feb 18 '11 at 20:33
  • @Konrad Rudolph: "can in principle be eliminated using statistics" Sadly, we're far too clever for that. Ask any social scientist or pollster. Also, I reject "eliminate" -- if you have some stats-based approach, you're only compensating. I prefer to actually eliminate the bias by eliminating it. And yes, the contradiction is inherent, making this award winning. It seems only you are deeply offended by this. Others have answered with their own approaches. Why did this offend you so deeply? – S.Lott Feb 18 '11 at 20:46
  • @Magnus Can you use your hand, or dose count as "tool"? – Amir Rezaei Feb 18 '11 at 21:22
  • 2
    @S.Lott No, Konrad isn't on his own. If anything is absurd, it is that you have expended your time and effort here for no perceivable or conceivable gain - other than to try and take someone down a peg. You're busy winning internet points by being the ubiquitous "guy who calls you an idiot". If you think it is so absurd, it would have involved far less personal effort to keep your distaste to yourself. That you were unable to do so is, in my view, award-winning. – Chris Feb 18 '11 at 22:02
  • @Chris: Good point. I forgot to ask for some definitions that would remove the contradiction between biased and random. Konrad says statistics might be able to overcome the bias, but this sounds like much more work than a set of dice. – S.Lott Feb 18 '11 at 22:06
  • @S.Lott To be honest with you, I'm not a fan of this defeatist attitude too but I didn't want to start a flame war about it. (And I don't particularly want to join in either.) All I can say is that this is a forum where we discuss ideas. Some ideas are more successful than others. But there's as much to learn from failed ideas than successful ones. This isn't a job, where you have to choose the most appropiate tools for the task. Just treat it as the thought experiment it is. – biziclop Feb 18 '11 at 22:27
  • So out of curiosity, what are you planning to use this for? Or was it just a thought experiment? – Inaimathi Feb 23 '11 at 15:19
  • 4
    This question appears to be off-topic because it is about the cognitive ability of an individual and not programming. –  Feb 12 '14 at 03:36

11 Answers11

42

Here is an algorithm from George Marsaglia:

Choose a 2-digit number, say 23, your "seed".

Form a new 2-digit number: the 10's digit plus 6 times the units digit.

The example sequence is 23 --> 20 --> 02 --> 12 --> 13 --> 19 --> 55 --> 35 --> ...

and its period is the order of the multiplier, 6, in the group of residues relatively prime to the modulus, 10. (59 in this case).

The "random digits" are the units digits of the 2-digit numbers, ie, 3,0,2,2,3,9,5,... the sequence mod 10. The arithmetic is simple enough to carry out in your head.

Davo
  • 436
  • 4
  • 2
  • This sounds really good. – biziclop Feb 18 '11 at 22:32
  • 4
    This may not be a problem for a particular person's needs, but this only gives you 90 different streams. – compman Feb 19 '11 at 03:59
  • @user9521 - I hadn't even thought of that when I upvoted. It's still a solution though; I don't think the OP wanted a way to generate cryptographically secure random numbers in your head (or at least, he didn't specify that). – Inaimathi Feb 19 '11 at 15:20
  • 6
    79, 79, 79, 79, 79, 79, 79, 79, 79, 79, oh noes! I assume you're supposed to stay <= 60, which works out well because you can use the clock for a seed if you don't have one. – eds Feb 19 '11 at 18:52
  • This is pretty cool. – Magnus Wolffelt Feb 20 '11 at 09:40
  • 4
    @eds Um, what? 79 -> 61 -> 15 -> ... – Izkata Jul 08 '14 at 19:05
  • 2
    Perhaps @eds meant 59. All numbers from 1-58 appear to be fair game. – Erhannis May 02 '15 at 02:14
  • Also, looking at the paper referenced: for additional utility, I calculate that you can do the same thing with 50 instead of 6, and the left 2 digits instead of just the left 1 digit, and get 498 numbers out of it. E.g., 15, 251, 75, 257.... – Erhannis May 02 '15 at 03:00
  • I've also calculated this. I checked replacing 6 with all values up to 100. In terms of how long before you see repeating numbers, 50 is the 5th best value (the best being 71). It is also the simplest to mentally multiply. Of seeds between 1 to 10,000, 20 seeds produce lists that repeat after 3 or fewer numbers. All other seeds produce lists of length 498 or more. Also, all of those lists are very uniform in the 1's digit. – Jonathan Heard Apr 28 '22 at 13:15
26

Check out this article on Geomancy. Specifically the section on generating Geomantic charts. It involves a pseudo-random number generating technique using binary digits and some simple recursive calculation. It seems like you could do this in your head fairly easily (though a piece of paper would help).

Disclaimer: I haven't tried it myself; when I need a sufficiently random number, I either get some output from /dev/random, use rand in whatever language I have handy, or roll my trusty d20.

If you're a math prodigy, the Middle-square method is a pretty computationally light, if noticeably unreliable method.

Inaimathi
  • 4,884
  • 1
  • 26
  • 34
  • 3
    +1 I think that this is the first serious answer to this question. A little sad. – Jens Feb 18 '11 at 13:00
  • @Magnus Wolffelt - I remembered it being mentioned in a TED talk by Ron Eglash about the cultural significance of fractal geometry in Africa; "Bamana Sand Divination". It's fairly interesting, though I still have no idea what you'd use this technique for now that we no longer need soothsayers. http://www.ted.com/talks/ron_eglash_on_african_fractals.html – Inaimathi Feb 18 '11 at 14:41
  • 1
    As far as I can see, that geomantic method simply allows you to 'improve' (I suppose that 'debias' would be a better term) a source of randomness. Not to be sneezed at, but not really what the OP was looking for. Which is not to say it's not pretty.... – Norman Gray Feb 18 '11 at 22:52
  • @Norman Gray - Human brains can come up with biased arbitrary numbers by default. – Inaimathi Feb 19 '11 at 01:43
  • @Inaimathi Precisely: that's why debiasing numbers would be important, and why the method you pointed to is helpful. Or I'm misunderstanding you. – Norman Gray Feb 23 '11 at 21:48
  • I recommend using `/dev/urandom` in almost all situations. `/dev/random` usually has horrible performance (and the advantage over urand is rather dubious), and `rand()` typically *sucks*. – CodesInChaos Feb 28 '13 at 09:33
10

I think a reasonable assumption is that you have to rely on the vast amount of verbal information you store in your brain. The source can be anything, song lyrics, poems, Monty Python sketches, but it has to be something you know by heart.

Then you have to select a fairly random part of it eliminating unconscious bias as much as possible. A way to do this for example would be to select a song, pick a number k between 10 and 20 and then find the kth letter in its lyrics.

Obviously this won't give you a uniform distribution in itself, as the frequency of letters is different, but it's a random letter nevertheless, or at least as close to it as I believe is possible without an external source.

Update: By the way, when people are asked to write a random sequence of say coin tosses, the most common mistake by far is to make your sequence "too random": runs of identical results will be too short, which a simple run length analysis will reveal. This method is mainly aimed at avoiding this trap. Of course other anomalies might arise from the shadow of this run length bias, but you'd need proper experiments to find them. Somewhat ironically, an algorithm for generating random numbers by thinking alone cannot be found by thinking alone.

S.Lott
  • 45,264
  • 6
  • 90
  • 154
biziclop
  • 3,351
  • 21
  • 22
  • Even then I would expect that you would be biased in a number of subtle ways. (IE tending to pick the same group of songs) – Zachary K Feb 18 '11 at 11:37
  • @Zachary K Without a doubt, but then you'd also have to pick a number, which spreads it a bit. Although bias could never be eliminated, this method almost certainly prevents you from knowing which letter you'll pick (although with time you're bound to memorise some). – biziclop Feb 18 '11 at 11:49
  • Eini mini miny moe, as we used to do as kids. – Zachary K Feb 18 '11 at 12:46
  • 2
    "pick a number k between 10 and 20". 17. The least random number. – S.Lott Feb 18 '11 at 13:16
  • @S.Lott It doesn't matter how random this number is. The only reason you need it is that you tend to remember the first few letters of things more easily. – biziclop Feb 18 '11 at 13:50
  • This is actually a pretty good answer.. maybe it can be streamlined for something more convenient.. I can't really recall the lyrics of that many songs.. maybe it's also possible to make it more uniform with some cleverness? – Magnus Wolffelt Feb 18 '11 at 16:04
  • @Magnus Wolffelt Any sufficiently large corpus would do, it just has to be something that is "solidified" memory, that doesn't change with every recall. It's just a rather sketchy idea anyway, but making it more uniform could be achieved for example by dividing the alphabet into letter sets of roughly equal frequency. – biziclop Feb 18 '11 at 16:28
9

Sample your watch.

I do this if I need a random number that's a factor of 60 (seconds). Take the appropriate modulo of whatever time it is. 4:17:23 PM, simulating a die roll, becomes 5.

Mark Canlas
  • 3,986
  • 1
  • 29
  • 36
  • And for a large number per minute? – Gary Feb 18 '11 at 16:20
  • Not sure I follow. You're saying make the pool of numbers 3600 by including minutes? I guess, but the larger the number the less random it would be? Like you couldn't rapidly take samples as easily. – Mark Canlas Feb 18 '11 at 16:32
  • 1
    @Gary Rowe This criteria has to be scrapped I'm afraid, simply because regardless of the method used, the human brain is simply too slow. – biziclop Feb 18 '11 at 21:24
  • Sorry, I was just wondering how your approach works if you need more than 60 numbers per minute. In hindsight, asking a human brain to produce that many numbers per minute is going to max it out anyway, so don't worry about it. – Gary Feb 18 '11 at 21:50
  • @biziclop No problems. Looks like I had a comment collision while considering the situation with @Mark's approach. – Gary Feb 18 '11 at 21:53
5

Excellent question. I fear that a good answer may prove very difficult.

But as a start, it’s quite easy to generate “true” randomness when two people are involved: simply let one of the people count silently in their head modulus some number, and the other say “stop” after an arbitrary interval. Afterwards, this number can be transformed into other distributions using standard methods.

To make this method robust, the modulus mustn’t be too large, otherwise there will be a strong bias against small numbers. I’d really be interested to see if there exists any work analyzing the stochastic properties of this method.

Konrad Rudolph
  • 13,059
  • 4
  • 55
  • 75
  • It’s important the counting is done fast, I think – the counting person should watch out not to count rhythmically, at only about 1 or 2 steps per second. Because there should be a significant number of cycles (intuitively ≥4) through all the numbers to achieve enough entropy. – Aaron Thoma Apr 28 '18 at 09:08
  • Improvement suggestion **for better randomness**: The counting person picks a secret random seed X₀ between 0 and modulus first; in combination with counting, that should provide decent randomness at still minimal thinking effort (even when counting slowly, relative to counting duration; i.e. low number of cycles – intuitively ≥2 would be fine; <2 would be okay-ish). – Aaron Thoma Apr 28 '18 at 09:10
4

This is a complex question; I'll try and explain a bit without wandering too far off into the weeds.

First, we have to ask "what is true randomness"? Such discussions quickly degenerate into philosophical waters, but the gist is this: "is the universe truly random"? In other words, if you quantize time and matter, can you compute the next state of the universe from the current one? If yes, then the universe is deterministic and there is no true randomness (see what I mean about "philosophical"?)

Because "true randomness" is difficult to define, we often settle for "pseudorandomness." This is generally required when generating "random" numbers on a computer, of course.

The simplest pseudorandom number generator would be something like Dilbert's famous "9.. 9.. 9.." algorithm. But intuitively it doesn't seem very good (which of course is the joke). Statisticians have developed a whole host of tests to say whether a sequence of purportedly random outputs are "good". Start with the wikipedia page for "chi squared test" and you could spend an afternoon just reading about these tests.

A simple computer algorithm like a "linear congruential generator" produces numbers good enough for a chi-squared test (you still need to "seed" this algorithm from something, however).

The next step up in "goodness" is "cryptographically strong randomness" which means that given a sequence a1, a2, ... you cannot predict the next number in the sequence with "reasonable probability" unless you use a lot of computation. These numbers are sometimes called "computationally pseudorandom." One common way to obtain such a sequence is via a "hash chain" like this: a1 = SHA512(a2), a2=SHA512(a3), ... Since we believe (based on experience, not mathematical proof) that SHA512 is computationally hard-to-invert, we believe that a2 is "impossible" to predict given just a1.

So now the question arises, what's the best thing humans can do under the rules stipulated in your question? Humans are notoriously bad at generating randomness; there used to be a web site that would have you attempt to generate coin flips by "randomly" typing H, T, T, H, H, T, T, etc. as if you were flipping a coin (but you do it in your head). After a while, the web site would start to predict your flips better than 50% of the time (using a Hidden Markov Model). We are just bad at this.

There are ways to improve the situation using various mixing techniques that are probably doable in your head. And there are even applications I could dream up for why you might want this (political prisoner wants to encrypt a message to outside allies). But I think this post is long enough. :)

Fixee
  • 531
  • 2
  • 7
  • 1
    Although whether a truly random physical process exists is open to debate (although experiments involving the EPR paradox suggest a positive answer), a theoretical definition of a random sequence does exist, based on Kolmogorov complexity. – biziclop Feb 18 '11 at 21:19
3

Highly randomised, large quantity per minute and generated by humans? Not gonna happen

The main problems you're going to run up against are

  • People get bored quickly so patterns will occur quickly
  • The human brain has a lot of structure devoted to pattern recognition/creation so you're going to have to defeat that
  • Truly random numbers contain repeats which humans try to avoid
  • Humans aren't good with large numbers

This led a lot of cryptographers to abandon "in-head" techniques in favour of external processes that were random because it was just too simple to work out patterns based on "in-head" numbers.

Off-topic but interesting

While it's not a mechanism for generating random numbers in your head, the Solitaire algorithm (as portrayed in Neal Stephenson's Cryptonomicon) demonstrates how difficult it is to use random numbers for cryptographic purposes. It requires only a pack of ordinary playing cards to create a reasonably secure output but the method to do is quite intricate.

Gary
  • 24,420
  • 9
  • 63
  • 108
  • 1
    I think this doesn´t answer the question. The 4 points of your answer only apply if people tried to find random numbers without an algorithm. I think the OP is aware of that and this is the reason why he asks for an algorithm that people can do in their heads and give good results, i.e. dont suffer the problems mentioned in your answer. – FabianB Feb 19 '11 at 14:23
3

The very reason for the proliferation of tool-based RNGs is that a good in-head algorithm for random number generation is yet to be developed.

Fortunately portable random number generators - including coins for the flopping, dice (with various numbers of facets) for rolling, cards for the picking and straws for drawing - are relatively easy to obtain at low cost. Moreover, for the technophiles amongst us, there are some rather good simulations of these tools available for most mobile platforms.

I would heartily recommend any of these over any meat-ware alternative.

Kramii
  • 14,029
  • 5
  • 44
  • 64
  • 1
    And these physical devices really do have an unpredictable nature to them, so in a sense they are more random than the best computer algoithms. – Omega Centauri Feb 18 '11 at 17:15
  • **(** @OmegaCentauri: Naturally I see what you did there! ;o) (Not sure the pun was intended, but I like it. :)   ) **)** – Aaron Thoma Apr 28 '18 at 08:27
2

I'm genuinely curious about anything that people might have come up with on this problem.

Please step away from the desk and go to Las Vegas.

Mankind has dozens of randomizing procedures. You can see all of them in Las Vegas.

You have spinning circles. You have tumbling cubes. And you have shuffled tokens. They all work marvellously well.

Cubes are perhaps the oldest. Apparently there were elongated 4-sided sticks used at one point. Symmetric cubic knucklebones of sheep were popular for millennia. We've been using those kinds of randomizers since -- probably -- about the same time we developed language.

http://itunes.apple.com/us/app/motionx-dice/id287509231?mt=8

"Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin”

--- John von Neumann

S.Lott
  • 45,264
  • 6
  • 90
  • 154
  • 7
    Downvoted - I'm not interested in external tools for generating random numbers, but rather in-head algorithms that can rely on memories or stimulus to generate truly random numbers. – Magnus Wolffelt Feb 18 '11 at 12:46
  • 3
    you can't roll dice in your head – jk. Feb 18 '11 at 12:51
  • 2
    @jk01: Correct. You can't do random in your head, either. – S.Lott Feb 18 '11 at 13:11
  • @S.Lott - I think what you mean to say is "A typical human can't generate consistently random numbers in their head at high speed using the naive method and no external tools". – Inaimathi Feb 18 '11 at 16:44
  • 1
    @Inaimathi. No, I'm saying something much stronger. You can't do random in your head. Your brain is packed with biases, so you need an algorithm. No finite, effective, deterministic algorithm is random. You simply cannot do it. No simple-enough algorithm is even pseudo-random, so you can't approximate random. Dice are small, handy and have a long, long history of use. – S.Lott Feb 18 '11 at 18:22
1

I can't think of any. In fact I would expect that anything you came up with would have so many biases in it that it would be worthless.

If I need random numbers I generally roll dice.

Timwi
  • 4,411
  • 29
  • 37
Zachary K
  • 10,433
  • 2
  • 37
  • 55
0

Are you asking for an LCM you can do in your head? Note that the idea that this is better than dice remains absurd.

However, this is as random as any finite, definite and effective algorithm can possibly be.

http://www.vias.org/simulations/simusoft_lincong.html

http://www1.i2r.a-star.edu.sg/~knandakumar/nrg/Tms/Probability/Probgenerator.htm

U_{k+1} = ( a \times U_k + b ) mod (m + 1).

It's easier to see what this is doing if we pick small values a=5, b=1, and m=7. You should be able to do that in your head.

S.Lott
  • 45,264
  • 6
  • 90
  • 154
  • I wonder if there is a decently random version of this ([linear congruential generator (LCG)](https://en.wikipedia.org/wiki/Linear_congruential_generator)), that is really easy to do in one’s head? a=1 ideally, a=2 second-ideally. (My thoughts so far on this in the next comment.) – Aaron Thoma Apr 29 '18 at 02:06
  • **((** I thought a=1, b prime, b cleverly chosen, could be a more feasible alternative for larger m’s, that would still work well. Then I noticed that’s probably not true: For b≈0 or b≈m, it will traverse rather sequentially through the numbers; so I thought b≈m/2 is the answer; but then I noticed, that could also be sequential (for small |b–m/2|/m), just at two positions alternatingly. For b≈m/3, it could be sequential, alternating among 3 positions; for b≈m/99 the problem wouldn’t be in alternating form anymore, but it would take ~99 steps to cycle through one modulo subtraction. **))** – Aaron Thoma Apr 29 '18 at 02:06