Benford's law: Difference between revisions
Content deleted Content added
m →{{header|Python}}: Make Python 3.X as well as 2.7 compatable |
→{{header|Python}}: Print percentages and deviation. |
||
Line 92:
res = [c/float(size) for c in f]
print("\n%s
for
print("%5.
def rand1000():
Line 106:
show_dist("random", islice(heads(rand1000()), 10000))</lang>
{{out}}
<pre>fibbed Benfords deviation
30.1% 30.1% 0.0%
17.7% 17.6% 0.1%
12.5% 12.5% 0.0%
9.6% 9.7% 0.1%
8.0% 7.9% 0.1%
6.7% 6.7% 0.0%
5.6% 5.8% 0.2%
5.3% 5.1% 0.2%
4.5% 4.6% 0.1%
threes Benfords deviation
30.0% 30.
17.7% 17.6% 0.1%
12.3% 12.5% 0.2%
9.8% 9.7% 0.1%
7.9% 7.9% 0.0%
6.6% 6.7% 0.1%
5.9% 5.8% 0.1%
5.2% 5.1% 0.1%
4.6% 4.6% 0.0%
random Benfords deviation
11.2% 30.1% 18.9%
10.9% 17.6% 6.7%
11.6% 12.5% 0.9%
11.1% 9.7% 1.4%
11.6% 7.9% 3.7%
11.4% 6.7% 4.7%
10.3% 5.8% 4.5%
11.0% 5.1% 5.9%
10.9% 4.6% 6.3%</pre>
|