Pi Day 2023 –Random PI
Using Random Processes to Estimate PI
In the past I have done a few PI Day blogs using Monte Carlo process to estimate PI:
-
Estimating Pi using normal distributons: https://dodecahedronbooks.blogspot.com/2020/03/pi-day-2020-pi-and-normal-distribution.html
-
Estimating Pi by shooting arrows at a circle: https://dodecahedronbooks.blogspot.com/2019/03/pi-day-2019-shooting-arrows-at-target.html
-
Estimating Pi with relatively prime numbers: https://dodecahedronbooks.blogspot.com/2018/03/pi-day-2018-prime-numbers-and-pi.html
-
Estimating Pi with Buffon’s Needle: https://dodecahedronbooks.blogspot.com/2017/03/pi-day-floor-pie-and-floor-pi.html
A Monte Carlo simulation makes use of random numbers to simulate some process many, many times, then takes some sort of average result. For example, the shooting arrows Monte Carlo was performed as below:
-
Create a random set of X and Y coordinates between -1 and +1.
-
Calculate the Euclidean distance of each set of coordinates from the origin (i.e. use the Pythagorean Theorem of D=sqrt(X*X + Y*Y).
-
Determine whether the point is within the unit circle (D<=1), or outside of the unit circle. Count the cases for each.
-
Determine (in/(in + out)), multiply that by 4 and that’s your estimate of Pi. In other words, this will be the ratio of a unit circle that is inscribed in a unit square.
I have shown a visualization of one run of the simulation, using 1000 points. Yellow points are hits within the unit circle, red are misses outside the unit circle.
This process converges rather slowly (100 runs of 1 million points gives a value of Pi=3.14163 as compared to the accepted value of 3.14159), so it isn’t a great way to estimate Pi, but it is a good way to show that a random process can estimate Pi (technically it is a pseudo-random process, as the Excel random number generator is not technically random.
Is the Expansion of PI itself Random
A question that arises, is whether or not Pi itself is random. Well, at least it does to me. We all learn rather early in school that Pi is a number that never ends and never repeats itself – also known as an irrational number. Somewhat later in school we may learn that Pi is a transcendental number, which is defined as being the solution to a certain type of equation – quoting Wiki: “not the root of a non-zero polynomial of finite degree with rational coefficients”.
But is it therefore random? After all, if it goes on forever and never repeats itself, it seems intuitively obvious that it must be random. Alas, it isn’t that easy. Here are a few quotes from some books that I happen to have:
“presented with a number x in the unit interval, unless it is a very special kind like a finite or repeating decimal, nobody knows how to determine whether x is normal. Nobody knows, for example, whether the decimal part of the number pi is normal even though pi has been calculated to perhaps as many as a billion places.” (The Pleasures of Probability, Richard Isaac, p 119)
“At the moment, it is beyond mathematics to show that, for example, pi has a random decimal expansion...What we can do, however, is test a long, finite piece of the decimal expansion of Pi for statistical randomness. With pi, we have a number whose decimal expansion has been carried out to more terms than any other number, and as far as I am aware the sequence of the digits appears to be statistically random. So, although we cannot (at present) prove the decimal expansion Pi random we can get a certain degree of confidence that this is so from the statistical analysis of a long finite piece of this expansion.” (The Pleasures of Probability, Richard Isaac, p 148)
I should note that in this case, the term “normal” does not have anything to do with the Gaussian (or normal) distribution. In fact it actually refers to a uniform distribution – if all of the digits in the decimal expansion of Pi (0 to 9) were counted, and ratios produced, each digit should have one-tenth of the total, then it would be considered to be a “normal” number. In fact, that is one of the key indicators of a random sequence of numbers.
The other is a lack of “serial correlation”. That has nothing to do with breakfast, but rather is a way of saying digits shouldn’t follow each other in some sort of a pattern. For example 012345678900112233445566778899000111222333444555666777888999...is normal (each digit shows up one-tenth of the time) but not random as it does show serial correlation.
The one way to be sure that a number is actually random, is if we are sure that it has been generated by a random process. One example of a random physical process is radioactive decay – the sequence of numbers that can be generated by this process is random because the process itself is random. As I understand it, the randomness of radioactive decay is a result of quantum mechanics, which is inherently random due to the uncertainty principle. Some sort of chaotic process might also work, to produce a truly random sequence of numbers.
There is one escape hatch from this, at least to an extent, as is noted below:
“Digits in the decimal representations of approximations to transcendental numbers, such as Pi or e, or simpler irrational numbers , such as root-two, have often been suggested as streams of independent discrete uniform numbers...Most statistical streams from Pi and e (usually in base 10) have not detected nonzero correlations or departures from uniformity.” (Random Number Generation and Monte Carlo Methods, James E. Gentle, page 43-44)
“A sequence of digits could be called statistically random if it passes a battery of statistical tests for randomness. This kind of randomness ignores how the digits are actually generated; it only requires sequences of them to pass the statistical tests. The concept of statistical randomness is of the greatest importance for computers, It allows computer -generated deterministic sequences to substitute for actual random sequences because the deterministic sequences are statistically random. Statistical randomness is a much more useful idea than just plain randomness – it substitutes the extremely appealing and practical guide of statistical testing for the usually impossible task of determining how the digits were generated. It is operational in nature: if it acts random then it might as well be random.” (The Pleasures of Probability, Richard Isaac, p 147)
I should note that there are a large number of tests that are used for checking the randomness of a string of numbers (or other symbols that you could map to numbers). The generally fall into two categories:
-
Goodness of fit tests (does the actual distribution of digits conform to the expected distribution?)
-
Serial correlation tests (do the runs of repeating numbers found match what would be expected from a random sequence?)
There are many variations of tests. The idea is to run the sequence against a battery of tests. If it passes them all, then it gets the all-clear. If it passes most, then it might still be accepted (a judgment call). These tests are especially important for determining the reliability of random number generators in computer packages, such as Excel, SPSS, Matlab, etc..
It has long been said that a team of monkeys bashing away on typewriters would eventually produce Hamlet. So, does that prove that the monkey bashing is not random, as defined above?
Suppose that the monkeys typed random garbage for 10 to the 50th power centuries, then Hamlet, then endless garbage again. Would the production of Hamlet prove that this was a non-random process? I think most people would say: “sort of, but not really”.
Coming back to Pi, Carl Sagan’s book “Contact” had a message from an alien species buried deeply in the expansion of Pi (base 11 or something like that). Would that actually be good evidence that the aliens exist, or is it just a weird fluke that you would eventually stumble upon in the far reaches of your way to infinity?
In theory I would say that it doesn’t prove their existence (we don’t know that Pi is actually a normal number) but in practice I would say that it does.
Sources:
Beckmann, Petr. A History of Pi (p. 101). St. Martin's Press. Kindle Edition.
The Pleasures of Probability, Richard Isaac, Springer.
Random Number Generation and Monte Carlo Methods, James E. Gentle, Springer, 2nd Edition.
So, now that you have dutifully read some Pi Day math, you should read a science fiction book, or even better, a whole series. Book 1 of the Witches’ Stones series even includes a reference to pi.:
Kati of Terra
How about trying Kati of Terra, the 3-novel story of a feisty young Earth woman, making her way in that big, bad, beautiful universe out there.
http://www.amazon.com/gp/product/B00811WVXO
http://www.amazon.co.uk/gp/product/B00811WVXO
The Witches’ Stones
Or, you might prefer, the trilogy of the Witches’ Stones (they’re psychic aliens, not actual witches), which follows the interactions of a future Earth confederation, an opposing galactic power, and the Witches of Kordea. It features Sarah Mackenzie, another feisty young Earth woman).
https://www.amazon.com/dp/B008PNIRP4
https://www.amazon.co.uk/dp/B008PNIRP4
The Magnetic Anomaly: A Science Fiction Story
“A geophysical crew went into the Canadian north. There were some regrettable accidents among a few ex-military who had become geophysical contractors after their service in the forces. A young man and young woman went temporarily mad from the stress of seeing that. They imagined things, terrible things. But both are known to have vivid imaginations; we have childhood records to verify that. It was all very sad. That’s the official story.”
A short story of about 6000 works.
https://www.amazon.com/dp/B0176H22B4
https://www.amazon.co.uk/dp/B0176H22B4
The Zoo Hypothesis or The News of the World: A Science Fiction Story
In the field known as Astrobiology, there is a research program called SETI, The Search for Extraterrestrial Intelligence. At the heart of SETI, there is a mystery known as The Great Silence, or The Fermi Paradox, named after the famous physicist Enrico Fermi. Essentially, he asked “If they exist, where are they?”.
Some quite cogent arguments maintain that if there was extraterrestrial intelligence, they should have visited the Earth by now. This story, a bit tongue in cheek, gives a fictional account of one explanation for The Great Silence, known as The Zoo Hypothesis. Are we a protected species, in a Cosmic Zoo? If so, how did this come about? Read on, for one possible solution to The Fermi Paradox.
The short story is about 6300 words, or about half an hour at typical reading speeds.
https://www.amazon.com/dp/B076RR1PGD
https://www.amazon.co.uk/dp/B076RR1PGD
No comments:
Post a Comment