Show More
@@ -20,7 +20,6 b' from __future__ import division, with_statement' | |||||
20 |
|
20 | |||
21 | import numpy as np |
|
21 | import numpy as np | |
22 | from matplotlib import pyplot as plt |
|
22 | from matplotlib import pyplot as plt | |
23 | from six import advance_iterator |
|
|||
24 |
|
23 | |||
25 | # Top-level functions |
|
24 | # Top-level functions | |
26 |
|
25 | |||
@@ -100,8 +99,8 b' def two_digit_freqs(digits, normalize=False):' | |||||
100 | Consume digits of pi and compute 2 digits freq. counts. |
|
99 | Consume digits of pi and compute 2 digits freq. counts. | |
101 | """ |
|
100 | """ | |
102 | freqs = np.zeros(100, dtype='i4') |
|
101 | freqs = np.zeros(100, dtype='i4') | |
103 |
last = |
|
102 | last = next(digits) | |
104 |
this = |
|
103 | this = next(digits) | |
105 | for d in digits: |
|
104 | for d in digits: | |
106 | index = int(last + this) |
|
105 | index = int(last + this) | |
107 | freqs[index] += 1 |
|
106 | freqs[index] += 1 | |
@@ -120,7 +119,7 b' def n_digit_freqs(digits, n, normalize=False):' | |||||
120 | freqs = np.zeros(pow(10,n), dtype='i4') |
|
119 | freqs = np.zeros(pow(10,n), dtype='i4') | |
121 | current = np.zeros(n, dtype=int) |
|
120 | current = np.zeros(n, dtype=int) | |
122 | for i in range(n): |
|
121 | for i in range(n): | |
123 |
current[i] = |
|
122 | current[i] = next(digits) | |
124 | for d in digits: |
|
123 | for d in digits: | |
125 | index = int(''.join(map(str, current))) |
|
124 | index = int(''.join(map(str, current))) | |
126 | freqs[index] += 1 |
|
125 | freqs[index] += 1 |
General Comments 0
You need to be logged in to leave comments.
Login now