%  Cantor's devil's staircase as a cumulative distribution function.

n=10^6
k=20

x=2*3.^-[1:k]*(rand(k,n)<1/2);

stairs([min(x) sort(x)],0:1/length(x):1) % Plot the c.d.f of x