I am looking for a method (exact, if possible, but at least asymptotically correct) for generating random variates from a [Cantor Distribution](http://en.wikipedia.org/wiki/Cantor_distribution)? It seems like its abstract definition prevents this. In essence, can one "invert" the [Cantor Function](http://en.wikipedia.org/wiki/Cantor_function#CITEREFScheeffer1884)?



Generating random variables from the Cantor Distribution
If $B\_j$, $j = 1 \ldots \infty$, are independent Bernoulli(1/2) random variables, then $X = 2 \sum\_{j=1}^\infty 3^{-j} B\_j$ has a Cantor distribution.
You could let $U$ be uniform on $[0,1]$ and take $B\_j$ to be the $j$'th base-2 digit of $U$ after the "decimal" point. 


