***Testing Normality of Pi, Console Example *** This page is under development. Comments are welcome, but please load any comments in the comments section at the middle of the page. Thanks,[gold] ---- [gold] Here is an eTCL script on testing the normality of [pi] for the etcl 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. For example, Kanada used a set of 6.4E9 decimal digits from [pi] and found the relative frequency of digit 7 as 600009044/6442450000 or 0.0931336749218077. 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 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. ---- Testcases frequency of "7" for collection of N digits of pi %|quantity|frequency|N |digits|website|% &|7|0.05 |20| digits|eveandersson |& &|7| 0.08510 | 50 |digits|eveandersson |& &|7|0.09313 | 1k |digits|eveandersson |& &|7| 0.09506 | 10k |digits|eveandersson |& &|7| 0.0989 | 100k |digits|eveandersson |& &|7| 0.10175| 500|digits|Kanada slice at 1.2E12|& ---- ***Screenshots Section*** relative frequency of "7" in pi mantissa approaches limit of 0.1 as N>>1 frequency versus set of PI digits of total N (decimal log N). statistics from pi314 website [http://img151.imageshack.us/img151/4917/dfdfmg.jpg] statistics from Kanada website relative frequency of "7" versus set of pi digits of total N (decimal log N). [http://img40.imageshack.us/img40/3659/ssssvs.jpg] ---- '''Comments Section''' Please place any comments here, Thanks. ---- ***References:*** * http://pi314.at/math/normal.html * http://mathworld.wolfram.com/NormalNumber.html * http://www.lbl.gov/Science-Articles/Archive/pi-random.html * http://www.geom.uiuc.edu/~huberty/math5337/groupe/digits.html * http://www.eveandersson.com/pi/digits/ * http://www.super-computing.org/ * http://www.piworld.de/pi-statistics/ * http://www.maa.org/mathland/mathtrek_12_16_02.html ---- ****Appendix TCL programs and scripts **** **** 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 0 0.0 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 results for small numbers of pi mantissa {14159265358979323846264338327950288419716939937} 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 results for 1k digits of pi 0 0.09117647058823529 1 0.11372549019607843 2 0.10098039215686275 3 0.1 4 0.09117647058823529 5 0.09509803921568627 6 0.09215686274509804 7 0.09313725490196079 8 0.09901960784313725 9 0.10392156862745099 results for 10k digits of pi 0 0.09486475891807135 1 0.10054880439043512 2 0.10005880047040376 3 0.09555076440611525 4 0.09917679341434732 5 0.10250882007056056 6 0.10005880047040376 7 0.09506076048608389 8 0.0929047432379459 9 0.09937279498235986 results for 100k numbers of pi mantissa 1 0.1000947923455181 2 0.09782372573414697 3 0.0989790074451488 4 0.09843592629895136 5 0.09899875585046508 6 0.09899875585046508 7 0.09898888164780693 8 0.09852479412287458 9 0.09777435472085629 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) 0 0.0912280701754386 1 0.07192982456140351 2 0.0824561403508772 3 0.06666666666666667 * 4 0.0824561403508772 5 0.11754385964912281 6 0.09824561403508772 7 0.10175438596491228 8 0.06842105263157895 9 0.09649122807017543 *note:repeating decimal, first one I've seen as r.f. ====== *** Code scraps*** ====== puts " timing split cmd [time { set lister [split {14159265358979323846} ""] } 1000 ]" ====== <> Testing | Toys | Performance | Numerical Analysis |Statistics| Example | Mathematics