-6
$\begingroup$

Confusion is possible, but we got numerical evidence against popular belief about the normality of $\pi$ in base two.

According to wikipedia

a real number is said to be simply normal in an integer base b if its infinite sequence of digits is distributed uniformly in the sense that each of the b digit values has the same natural density 1/b. A number is said to be normal in base b if, for every positive integer n, all possible strings n digits long have density b^-n.

Working with precision ten thousands binary digits and n=2, the counts of the strings in $\pi$ are: $(11: 1661, 10: 2505, 01: 2505, 00: 1659)$

$10$ occurs about 1.5 times more than $11$.

$\pi$ appears to be simply normal in base four.

The same discrepancy happens for $\sqrt{2}$, $\log{3}$ and large random integers.

Is $\pi$ not normal in base two and $n=2$?

Computations were done with sagemath and pari/gp.

Added The shorter of the two programs, are there obvious bugs in it?

 sage: pre=10^4
 sage: gp.default('realprecision',pre)
 0
 sage: sp=gp.binary(gp.Pi())
 sage: sp2=eval(str(sp[2]));sp3="".join(str(_) for _ in sp2)
 sage: sp3.count('11'),sp3.count('10'),sp3.count('01'),sp3.count('00')
 (5586, 8289, 8290, 5529)
$\endgroup$
15
  • 3
    $\begingroup$ How could this happen for random integers? Also, shouldn't your numbers add up to 10000? $\endgroup$
    – Will Sawin
    Commented Mar 6, 2020 at 15:03
  • 1
    $\begingroup$ They should still add up to 10000 (give or take a few): the first 10000 bits contain 9999 consecutive bit pairs $\endgroup$
    – Wojowu
    Commented Mar 6, 2020 at 15:17
  • 3
    $\begingroup$ From the data, we can tell with high confidence, without looking in the spec, that count does not allow overlaps. $\endgroup$
    – Will Sawin
    Commented Mar 6, 2020 at 15:45
  • 2
    $\begingroup$ e.g. see line 230 of github.com/python/cpython/blob/master/Objects/stringlib/… $\endgroup$
    – Will Sawin
    Commented Mar 6, 2020 at 15:55
  • 4
    $\begingroup$ I'm voting to close this question as off-topic because the comment strongly suggests the numerical data is just wrong. $\endgroup$ Commented Mar 6, 2020 at 17:52

1 Answer 1

6
$\begingroup$

This is more of a comment. I wanted to share the code I have used to provide values in my comment above.

s00 = 0
s01 = 0
s10 = 0
s11 = 0
a = 0
b = 0
P = pi
for i in range(10000):
    a = b
    b = floor(P)%2
    P = 2*P
    if a==0 and b==0:
        s00 += 1
    if a==0 and b==1:
        s01 += 1
    if a==1 and b==0:
        s10 += 1
    if a==1 and b==1:
        s11 += 1
print s00,s01,s10,s11

This code returns 2510 2505 2505 2480. I'm afraid I cannot comment on what is wrong with your code.

$\endgroup$
2
  • $\begingroup$ Thanks, your code seems reasonable, will check $\endgroup$
    – joro
    Commented Mar 6, 2020 at 15:53
  • 1
    $\begingroup$ The bug in my code was found, I incorrectly didn't count overlaps. $\endgroup$
    – joro
    Commented Mar 6, 2020 at 16:30

Not the answer you're looking for? Browse other questions tagged .