Has someone run across a method for generating random variates from a Cantor Distribution? It seems like its abstract definition prevents this. In essence, can one "invert" the Cantor Function?


1 Answer 1


One way of looking at a random variable with a Cantor distribution is to start with a sequence of iid random variables $X_n$ that take values 0 and one with probability $\frac{1}{2}$ (think random bits, or fair coins). Then our Cantor random variable is $$Z=2 \sum_{n=1}^\infty \frac{X_n}{3^n}.$$ A particularly nice source of independent random bits is the bits in a uniform (0,1) random variable.

Of course, given finite time you only get finite precision, but the same is true of standard simulated random numbers. Since the cantor distribution is continuous, you can get as close as you need to.

  • $\begingroup$ +1. But actually, the standard Cantor random variable is twice the Z you wrote. $\endgroup$
    – Did
    Jan 1, 2016 at 23:15
  • 4
    $\begingroup$ +1. A software implementation of this solution appears at stats.stackexchange.com/questions/229556. $\endgroup$
    – whuber
    Aug 12, 2016 at 15:41

You must log in to answer this question.