## Testing Normality of Pi, Console Example

This page is under development. Constructive comments are welcome, but please load any constructive comments in the comments section at the bottom of the page. Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you. Aside from your courtesy, your wiki MONIKER and date as a signature and minimal good faith of any internet post are the rules of this TCL-WIKI. Its very hard to reply reasonably without some background of the correspondent on his WIKI bio page. Thanks, gold 08Jul2020

## Introduction

gold Here is a TCL script on testing the normality of pi in the TCL console. It has not been mathematically proven that pi is a normal number, but numerical analysis with TCL can check for some aspects of normality in pi. The normality of a number means that the ten numbers (0,1,2..9) in the mantissa are equally common at infinity. Relative frequency is count of individual numbers (eg. digit 7) over the set of digits (10 in base ten) at collection size N. If pi is normal in base 10, the relative frequencies of each digit in the mantissa approach 1/10 as N approaches infinity. The script below was used to check the relative frequency of pi digits using the published collections of pi.

In planning any software, there is a need to develop testcases. With back of envelope calculations, we can develop a number of peg points to check output of a TCL program. For the first 20 digits of pi, one counts 2 ones so the relative frequency of one using 2/20 should be 0.1. Also for the first 20 digits of pi, one counts 3 nines so the relative frequency of nine using 3/20 should be 0.15. In the first 20 digits of pi, one finds no zeros. This means that the relative frequency of digit zero using 0/20 should be zero. In the results below, one can see the relative frequencies of 0,1,&9 digits. The sum of the relative frequencies for all decimal digits 0,1,2 ... 9 should approximate 10 times .1 or 1.0. Other testcases could be from slices of pi digits from the big number crunchers. A slice of published Kanada sequence of pi digits can be loaded into the TCL script on the console.

## Speculations on Normality of Pi

Probably numerical coincidence in the first 20 digits of the pi mantissa, but note that the even digits of 2,4,6,&8 have the average of 0.1, like the even digits would at infinity in theory.The average of the even numbers is eval </ <+ .1 .1 .1 .1 ] 4.> or 0.1, as might be expected. The average of the odd numbers is eval M/ <+ .15 .15 .05 .15] 4.] or 0.125 , slightly higher.If pi is normal at infinity, then the average frequency of all digits of 0-9 should average eval </ <+ .1 .1 .1 .1 .1 .1 .1 .1.1 ] 9.> or 0.1. Restating the original premise, the sum of the estimated frequencies for all digits in the pi mantissa should equal to one, meaning at infinity. For the first 20 digits of pi, the sum of frequencies for the 0-9 digits <+ 0. .1 .1 .15 .1 .15 .1 .05 .1 .15> equals 1.0. If not a real proof over the entire number line, at least the sum for frequencies of first 20 digits agree with the restated premise. For the first 10K digits of pi, the sum of 0-9 frequencies was 0.9801058. The “relative error” in the sum of frequencies was 2.02 percent for the first 10k digits. The difference or “absolute error” from the condition at infinity was <- 1. 0.9801058> or 0.0198941. Not sure these results for pi can be extended to other bases, but possibly for pi in base N1, the N1 digits of base N1 should have an average frequency of 1/N1.

## Testcases

frequency of "7" for collection of N digits of pi

quantityfrequencyN digitswebsite
7 0.10175 500digitsKanada slice at 1.2E12,http://www.super-computing.org

### * Pretty Print Version

```               # Pretty print version from autoindent
# and ased editor
# written on Windowws XP on eTCL
# working under TCL version 8.5.6 and eTCL 1.0.1
# gold on TCL WIKI , 25may2011
# relative frequency of indiv. "throw" over all "throws".
# pi mantissa used here
package require Tk
console show
proc calculation {  facen }  {
# prob. subroutines for mimic sequence of bronze
# prob. is throw combos of eg. "7" over all possible throws

set lister [split {14159265358979323846} ""]

set ee [llength  \$lister ]
set kk [ llength [ lsearch -all \$lister \$facen ] ]
set prob [ expr { (\$kk*1.) / \$ee  } ]
return \$prob
}
set limit 12
for { set i 0 } { \$i <= \$limit }  { incr i } {
lappend listxxx \$i
lappend listxxx [ calculation  \$i ]
puts " \$i [ calculation  \$i ] "
}
#end```

## results for first 20 numbers of pi mantissa

`set lister [split {14159265358979323846} {}]`
table printed inTCL format
quantity value comment, if any
0 0.0 20 in pi mantissa
1 0.1
2 0.1
3 0.15
4 0.1
5 0.15
6 0.1
7 0.05
8 0.1
9 0.15
10 0.0

## results for small numbers of pi mantissa

`set lister [split {14159265358979323846264338327950288419716939937} {}] `
table printed inTCL format
quantity value comment, if any
0 0.02127659574468085
1 0.0851063829787234
2 0.10638297872340426
3 0.1702127659574468
4 0.0851063829787234
5 0.0851063829787234
6 0.0851063829787234
7 0.0851063829787234
8 0.10638297872340426
9 0.1702127659574468
10 0.0

## results for 1k digits of pi

table printed inTCL format
quantity value comment, if any
0 0.09064327485380116 1k in pi mantissa
1 0.11306042884990253
2 0.10038986354775828
3 0.09941520467836257
4 0.09064327485380116
5 0.09454191033138401
6 0.09161793372319688
7 0.09259259259259259
8 0.09844054580896686
9 0.10331384015594541
10 0.0

## results for 10k digits of pi

table printed inTCL format
quantity value comment, if any
0 0.0968096809680968 10k in pi mantissa
1 0.10261026102610261
2 0.10211021102110211
3 0.09740974097409741
4 0.10121012101210121
5 0.10461046104610461
6 0.10211021102110211
7 0.09700970097009701
8 0.09470947094709471
9 0.10141014101410141
10 0.0

## results for 100k numbers of pi mantissa

table printed inTCL format
quantity value comment, if any
0 0.09872630331753554 100k in pi mantissa
1 0.10009873617693522
2 0.09782780410742496
3 0.09898301737756714
4 0.09843996840442339
5 0.09900276461295418
6 0.09900276461295418
7 0.09898301737756714
8 0.09851895734597156
9 0.09776856240126382
10 0.0

## results for 1E6 numbers of pi mantissa

table printed inTCL format
quantity value comment, if any
0 0.09799911568540753 1E6 numbers of pi mantissa
1 0.09780205666868301
2 0.09806480202431571
3 0.0982638218272763
4 0.09826480222039434
5 0.09839127293262052
6 0.09759617411389619
7 0.09784323317964037
8 0.09802460590647638
9 0.0981432334737583
10 0.0

## slice of published Kanada sequence of pi digits.

500 digits ending 1,241,100,000,000-th (1,241,099,999,501 - 1,241,100,000,000)

table printed inTCL format
quantity value comment, if any
0 0.0912280701754386 500 digits in Kanada slice
1 0.07192982456140351
2 0.0824561403508772
3 0.06666666666666667 * repeating decimal, first one I've seen as r.f.
4 0.0824561403508772
5 0.11754385964912281
6 0.09824561403508772
7 0.10175438596491228
8 0.06842105263157895
9 0.09649122807017543
10 0.0

### Notes & Code scraps

Here vowels are equal probilities to consonants. Maybe vowels should be set to equal prob. in English or other language.

```   # test of transmuting integers of pi into words and letters.
# [Mapping words to integers]
# Small program for console
console show
source int2wordetc.tcl
set bid  "14159265358979323846264338327950288419716939937510"
puts " word  [ int2word   \$bid ]"
#output
#jzilvrzbjfkfzpwznsqdbwjzsjzeqfxkvop
```