My curiosity came from a lottery game. When you are choosing numbers in an interval you tend to choose some numbers that are relevant to you, when the result of the game is shown you think you wouldn't have chosen those numbers even if they were given to you previously to the drawing.

Of course, you can use a program to that, but how would a person do the work?

I think that this would be impossible since you are always a "victim" of your psychological set of mind, but I am not really sure.

Is there a way for a person to chose numbers randomly?

  • 1
    $\begingroup$ Might be interesting to peruse Knuth's discussion of producing random numbers in vol. 2 of "Art of Computer Programming". $\endgroup$ – copper.hat Dec 20 '15 at 18:54
  • 2
    $\begingroup$ Rolling dice or flipping coins isn't bad unless you have some training (e.g. Persi Diaconis). $\endgroup$ – Batman Dec 20 '15 at 18:57
  • $\begingroup$ @Batman How would that work if I had to choose numbers between 1 and 100, for instance? $\endgroup$ – StillBuggin Dec 20 '15 at 18:59
  • 3
    $\begingroup$ @Batman Flipping a coin is MUCH better than rolling dice, since dice are sensitive to small deviations in edge shapes (and weight distribution) while coins are extremely robust to small and even medium shape/weight deviations - especially if caught in the air. $\endgroup$ – A.S. Dec 20 '15 at 19:01
  • 1
    $\begingroup$ Grab a d10 from your DnD set, roll twice. First roll gives you first digit, second roll gives you second digit in $0$ to $99$. If you can't get exactly the right number with what you have, you can generate a bigger number and do modulo (which will introduce some non-uniformity), but if you're generating numbers by hand it likely doesn't matter. $\endgroup$ – Batman Dec 20 '15 at 19:05

On generating random numbers by hand:

For most people, rolling dice or flipping coins isn't a bad idea (exceptions: Persi Diaconis, magicians, etc. are known to have some degree of control where they can bias a coin or dice roll). We'll assume all coins/dice are fair for the remainder of this discussion and each flip/roll is independent of the others, though this may not always be good (link1, link2). We'll also assume you want to generate uniform random numbers unless otherwise noted (which we talk about a bit at the end).

If you want to generate a value in 0 to b^d -1 and you have a b-sided die, you just roll the die b times, and use those values as the digits of the number. For example, if you want to generate a number from 0 to 99, go grab a d10 from a Dungeons and Dragons dice kit, roll twice. The first number is the first digit, second number is second digit. You can extend this to the case that if you have multiple types of dice, you can generate numbers uniformly. For example, if I wanted numbers between 0 and 19, I could flip a coin to get the first digit, and then roll a d10 to get the second digit. Or, since I'm presumably getting a d10 from a DnD dice kit, its probably better just to roll a d20.

If you don't have such a situation, you could generate a larger random number and reject numbers which don't fall into the desired interval, or do modulo (this may introduce a bias, due to the pidgeonhole principle, since some numbers may be more frequent modulo the interval length, depending on if the interval length evenly divides the range of numbers you're generating). On a computer, you may want to use random number generators like arc4random_uniform or something to deal with this. As an illustration for the modulo issue, consider generating a number 0,1,2 but I only have access to a coin. One way to do this would be to flip a coin twice (so i get 0,1,2,3 equally) and take the modulo 3 of it. But, 0 and 3 both are 0 mod 3, so the distribution I'd get is $(1/2, 1/4, 1/4)$, not $(1/3,1/3,1/3)$. On the other hand, if I just threw away cases where I got a 3, I'd get the right distribution $(1/3,1/3,1/3)$.

Another option is to make cards with the numbers desired on them, shuffle them well (this is a harder mathematical problem than it looks at first glance) and then draw a card. Note that once you draw a card though, you can't just discard it (else you won't get that number again!). A rule of thumb is that 7 riffle shuffles is sufficient, but you can look at the references in this paper by Diaconis or the previous articles on how good that is in a precise mathematical matter.

There are also tables of random numbers, which were used often in the pre computer era.

Theres a nice discussion on how to generate numbers from fair coin flips in Cover and Thomas' Elements of Information Theory, Sec. 5.11, 2e. Assume we want to generate a sample from a distribution taking values 1,...,m with probabilities $p_1,\ldots,p_m$. Make a (possibly infinite) binary tree corresponding to the left node having 1 and right node having zero, and each node corresponds to the value of the binary expansion of its parents treated as a binary decimal. You can map the distribution $p_1,\ldots,p_m$ to nodes in the tree and flip coins to go down the tree until you say you get a sample from the desired distribution. One can prove that you may need at most 2 more coin flips on average than the theoretically limit (the (binary) entropy). Of course, from a practical perspective, this may be somewhat time consuming. Knuth's The Art of Computer Programming has some old information, as do many other resources on the internet.

On Independence and random variables:

My curiosity came from a lottery game. When you are choosing numbers in an interval you tend to choose some numbers that are relevant to you, when the result of the game is shown you think you wouldn't have chosen those numbers even if they were given to you previously to the drawing.

This is a different idea than what we discussed before: Before, we discussed "I have a distribution and I want to draw a sample from this distribution." In what you're asking about, you're talking about independence. That is, the probability of drawing something at this time does not depend at all on previous draws.

These concepts are different. For example, a Markov chain in its stationary distribution will always have the same distribution at any time, but the draw you get at time $n$ given you knew what was drawn at time $n-1$ can be different depending on what was drawn at time $n-1$.

Also, one should not conflate a realization of a random variable with the random variable itself.

  • $\begingroup$ Oh, Gosh! That's great! Thank you so much!!! I really appreciate that answer. $\endgroup$ – StillBuggin Dec 20 '15 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.