Let’s first look at the first 100 000 digits of pi in binary and see what we get if we summed them (plotting the
sum versus the number of digits). As expected we something that looks like a straightline with slope 1/2. Why? Because the
average value of the digits is 1/2 and each "random" digit in binary-pi contributes on average 1/2.
Pi ~ 11.0010010000111111011010101000100010000101101000110002
50 000
40 000
30 000
Out[1]=
20 000
10 000
0
20 000 40 000 60 000 80 000 100 000
Now let’s say we subtract off this average digit of 1/2 that we add each time, to see what the distribution of the digits actually looks
like. Looks like a random walk to me.
1
In[2]:= b = 2; n = 100 000; r = Π; ListLinePlotBAccumulateBFirstBRealDigits@r, b, nD - FF,
2
Filling ® Axis, PlotLabel ® "Pi ~ " BaseForm@N@r, 16D, bD, ImageSize ® 8500, 350<,
ImagePadding ® 8825, 25<, 825, 25<<, PlotRange ® 881, n<, All<, AxesOrigin ® 81, 0<F
Pi ~ 11.0010010000111111011010101000100010000101101000110002
200
150
100
Out[2]=
50
0
20 000 40 000 60 000 80 000 100 000
-50
Now what about your weird thing where 0 are mapped to 1/3 and 1’s are mapped to 1/2. Let represent this transformation from x
-> y ({0,1} -> {1/3, 1/2}) as y = 1/3 + x/6 (you can check it works for x=0, and x=1). Then we get your straight line, with expected
slope of 1/3+1/12=5/12 ~ 0.416666
1 1
In[3]:= b = 2; n = 100 000; r = Π; ListLinePlotBAccumulateBFirstB HRealDigits@r, b, nDL + FF,
6 3
Filling ® Axis, PlotLabel ® "Pi ~ " BaseForm@N@r, 16D, bD, ImageSize ® 8500, 350<,
ImagePadding ® 8835, 25<, 825, 25<<, PlotRange ® 881, n<, All<, AxesOrigin ® 81, 0<F
Pi ~ 11.0010010000111111011010101000100010000101101000110002
40 000
30 000
Out[3]=
20 000
10 000
0
20 000 40 000 60 000 80 000 100 000
Again if we simply subtracted off the average value of 5/12, we would recover the random pattern.
1 1 5
In[4]:= b = 2; n = 100 000; r = Π; ListLinePlotBAccumulateBFirstB HRealDigits@r, b, nDL + - FF,
6 3 12
Filling ® Axis, PlotLabel ® "Pi ~ " BaseForm@N@r, 16D, bD, ImageSize ® 8500, 350<,
ImagePadding ® 8835, 25<, 825, 25<<, PlotRange ® 881, n<, All<, AxesOrigin ® 81, 0<F
Pi ~ 11.0010010000111111011010101000100010000101101000110002
30
20
Out[4]=
10
0
20 000 40 000 60 000 80 000 100 000
-10
Note the basis for this code was taken from a Wolfram web demo to display the digits of pi
(http://demonstrations.wolfram.com/RandomnessInTheDigitsOfPi/). The same thing would work for other irrational constants;
e.g. Sqrt[2], but wouldn’t work for rational fractions. Say 1/7 which even when subtracting off the average value of a 1 and 0, still
appears to be a straightline.
Sqrt@2D ~ 1.01101010000010011110011001100111111100111011110011012
50 000
40 000
30 000
Out[5]=
20 000
10 000
0
20 000 40 000 60 000 80 000 100 000
1
In[6]:= b = 2; n = 100 000; r = Sqrt@2D; ListLinePlotBAccumulateBFirstBRealDigits@r, b, nD - FF,
2
Filling ® Axis, PlotLabel ® "Sqrt@2D ~ " BaseForm@N@r, 16D, bD, ImageSize ® 8500, 350<,
ImagePadding ® 8835, 25<, 825, 25<<, PlotRange ® 881, n<, All<, AxesOrigin ® 81, 0<F
Sqrt@2D ~ 1.01101010000010011110011001100111111100111011110011012
50
0
20 000 40 000 60 000 80 000 100 000
-50
Out[6]= -100
-150
-200
-250
1 1
In[7]:= b = 2; n = 100 000; r = ; ListLinePlotBAccumulateBFirstBRealDigits@r, b, nD - FF,
7 2
Filling ® Axis, PlotLabel ® "17 ~ " BaseForm@N@r, 16D, bD, ImageSize ® 8500, 350<,
ImagePadding ® 8835, 25<, 825, 25<<, PlotRange ® 881, n<, All<, AxesOrigin ® 81, 0<F
17 ~ 0.00100100100100100100100100100100100100100100100100100102
0
20 000 40 000 60 000 80 000 100 000
-5000
Out[7]=
-10 000
-15 000