What is the longest known sequence that repeats in Pi? (homelab)
sponaugle.com
sponaugle.com
Very much appreciate the amazing effort that is OEIS!
I thought I should mention it to raise awareness: https://oeis.org/
The sequence in the article: https://oeis.org/A197123
https://www.youtube.com/playlist?list=PLt5AfwLFPxWJXQqPe_llz...
It contains, well, factorization of many numbers.
For example here's RSA-250:
https://factordb.com/index.php?query=21403246502407449612644...
I hope sites like these continue to exists for a very long time.
I'd link to one or two other useful oldschool sites that I do still use but I'm not sure they could handle the /. (well, HN) effect.
filters = {}
candidates = []
for i in range(len(pi)):
block = pi[i:i+10]
hash_prefix = block[:4]
try:
bloom = filters[hash_prefix]
except KeyError:
filters[hash_prefix] = BloomFilter().add(block)
candidates.append((i, block))
continue
if block in bloom:
candidates.append((i, block))
else:
bloom.add(block)
Basically, make one pass through to build a list of statistically likely candidates to evaluate later. Then use full string matching on those candidates to find the real matching sequences.That might be helpful here because Bloom filters can say "we might have seen this string before" or "we definitely have not seen it before". That may greatly reduce the amount of storage you need.
I'll take a crack at doing this - It could certainly be an improvement and would just be fun to try out.
Digging in to estimate the speed, if your Bloom filter has a 0.1% chance of a collision then a trillion digits of pi will result in a billion candidates. This requires ~15 bits per entry or about 2TB of memory for the full Bloom filter. Using multiple passes on subsets of the data allows you to trade speed for space.
Note also that a 128 bit integer has room for 38 digits. This means that you can do all of the shifting using modulo, multiplication and addition operations. I would be very surprised if the cost of the disk I/O to read the raw digits is as fast as the sieving of candidates. As such, the speed of a single pass should be about the cost of reading about 500GB of data which means that multi-threading will be of limited use. This should be less than an hour on most machines. That means that one of my ancient Intel NUCs with 32GB should be able to scan the entire range in about a day no matter what size sequence we are looking for.
Thanks for being that someone.
That said, I’m curious now. I also refuse to allow myself to dig further into it. I’ve got enough spinning plates at the moment. :-)
Consider pi[i:i+10] and pi[i+1:i+11] they are highly similar. Intuitively it seems that storing them both seems wasteful. But how can we avoid storing them both? This is where we have to get clever.
We are looking for a length 18 match. If position a and position b are a length 18 match, then it holds that (a,b) is a length 10 match. (a+1,b+1) is also a length 10 match, and so is (a+2,b+2). Wouldn't it be nice if we could store only one of a,a+1,a+2 etc?
The naive attempt is to do the loop with a stride of say 3, but this will not work as it may happen that e.g. a=1 mod 3 and b=2 mod 3.
However there is another approach that does work. We need to use a position-independent way of deciding between a,a+1 etc. We can do it thusly. Loop over all the numbers. When we encounter position a we score the length 10 sequences starting at a, a+1.. a+8. Any scoring function will do as long as it doesn't have ties. For simplicity we can score=number. The highest scoring number is stored. As an implementation detail we can use a "sliding window maximum" algorithm to avoid recomputing and recomparing the scores.
Note that in this scheme we may actually end up storing more than one of a, ..a+8. But it will cut down the storage quite a bit at least.
Edit: It should also be mentioned that due to the conjectured normality of pi, comparing two sequences will on average terminate very quickly, just looking at one or two digits will be enough most of the time, so a comparison is expected O(1).
Finding random numbers repeating is a simple brute force problem. It is cool, but slightly boring.
Related to this, what I cannot wrap my head across, is the Infinite monkey theorem. Is it not possible that we keep expanding the numbers and never reach a complex enough set of values?
"to be or not to be" may be more likely for a monkey on a keyboard to generate than a random string, actually. The keys to generate it are highly repetitive and relatively close together. That's true for any NL string: the lower entropy of NL strings are reflected in the keyboard layout. If the monkeys switch to Dvorak, they could probably generate Shakespeare even faster.
Of course not. There are lots of ways you can bias random that remain random, but prevent every possible output from being generated. That's all GP was saying. You can't just say "infinite time", you need to rule out biases that would prevent the desired result.
What, you egg?
[He stabs him.]
(from Macbeth)Are you certain the real thing isn't "the blurst of times" already?
https://preview.redd.it/it-was-the-best-of-times-it-was-the-...
Worse, they can’t even tell their Shakespeare from their Dickens (It’s the opening line of A Tale of Two Cities).
It does represent something 'interesting' that is easy to observe and wonder about, and for the non-math person it leads to slightly better understanding of 'normal' numbers, of the difference in representation ( these answers are base specific), and a very small amount of simple computer science.
The notion of world record is of course tongue in cheek. No one really needs to know these numbers, nor will they rememeber them! But at least there is an entry in OEIS!
Hypothetically that could be found in pi, right? Of course, it ended up being spread widely enough that they gave up on trying to police it. But maybe there are some other not-allowed numbers that could be distributed as a position in pi? I’m not sure what the point would be, mostly just to make a point I guess.
[1] https://github.com/lifthrasiir/remote-pi-reader/
[2] https://storage.googleapis.com/pi100t/index.html (used to be `pi50t` back then)
Do N passes over the data, and at each pass only put in your hashmap the values that mod N equal the current iteration. If you take N~100, the runtime would probably be in the same ballpark, since the only thing that increase is streaming all the data N times. With a fast SSD, that's not that much.
Those runtimes seem quite a lot slower than what I would have expected, and I'm pretty sure they could be optimized by a lot, especially since he sounds like he has enough RAM to hold the entire file.
Not trying to be dismissive, but this doesn't sound like that great of an implementation.
I think with some good optimization you could reduce the runtime significantly, especially on modern hardware.
As for RAM limitations - You are correct the only limitation is just that with the RAM I have I would need to do more iterations. It would be possible to do this in much less RAM with more iterations, or the reverse of course.
I was fond of solving the problem in RAM just as a way to limit the scope of the problem... but SSDs are indeed pretty fast at streaming data like this.
He makes a great optimization, by using hash tables, but I was wondering about optimizing about the evaluation of the Chi-Square Test for Equal Proportions.
If the Chi-Square test diverges from the Chi-Square Test for e, then there is little likely hood for pi+e to ever converge on rationality.
My hypothesis is that because Pi is cyclical, and e is exponentially transcendental, that their sum and product are not rational, and nether are their respective powers ( Pi^e and e^Pi ), but those will take a much larger homelab than I have access to.
PI isn't random. It is exactly the ratio of a radius and the circumference of the circle.
Incommutability is not the same thing as 'random'. PI does not follow any sort of probability or statistical algorithm to be generated. Nothing inside PI is random...
Now... if you take a random number (introducing randomness in the first place) representing the position and another random number to represent the length. From PI those two random numbers will generated a random sequence. But the 'randomness' is not IN PI, the random elements are only in the 2 chosen numbers. I understand this is colloquially what people mean when they say PI is 'random'...
Randomness can only come about from choice, and the digits of PI have no choice as to what they will be. You can not read out a deterministic sequence of numbers in order and expect randomness. The randomness must come from some choice interacting with that defined sequence of numbers.
Do the digits of Pi pass statistical tests for randomness? Uniform distribution, etc?
https://blogs.sas.com/content/iml/2015/03/12/digits-of-pi.ht...
Seriously, I find the most interesting works self-published in people’s personal blogs and I often wonder if there’s a paper in there and why it didn’t make it into a paper.
Maybe there’s a paper in finding the largest repeating sequence in Pi. There have certainly been more niche papers than that.
01001000100001...
I am not familiar with how a proof of that would be constructed, as clearly numerical or computational measurements could never be conclusive.
01000100
But maybe I don’t understand your exampleThere may be some long repeats, but not all sequences repeat. Thanks!
Using the pigeonhole principle, there must be at least one length N repeating string in the first N(N!+1) characters of any string.
I _think_ you can but my brain doesn't have the bandwidth to think past that.
This is suspected but currently not yet proven.
In fact, we don't even have a proof yet that the digit 7 occurs infinitely often in pi. (Same for any other digit.) Right now it's conceivable, but very unlikely, that there is some final 7 in pi.
It is however something fun to do in a homelab outside of the normal learning and playing around, and that has merit for me. Hobbies are hobbies in part because of the interest, joy and appreciation they drive.
In another sense you're very wrong. The set of uncomputable numbers also has measure 1. So while there are lots of normal numbers Pi belongs to a pretty exclusive club of numbers we can actually look at.
It's not a particularly deep result but the fact that the set of computable numbers is countable will never not make me existential. Every number that we can actually express, that we will ever know, is no bigger than the whole numbers.
Let's say we knew we had a normal number, say we could prove pi is normal. Then the set of sequences defined by the decimal expansion of pi starting at the nth place for all n in the natural numbers would be uniformly random over all decimal expansions. I'm going this route because it in theory allows us to define each sequence by virtue of a single number rather than an infinite sequence of randint(0, 9). This I think would be our best case if it were possible. But you would have to select a number uniformly in the range [0, inf) which... you can't.
[1] https://en.wikipedia.org/wiki/Normal_number#Properties_and_e...
But in contrast to that, I'm also happy to grant the existence of constructions with countably infinite length when discussing theories outside of computability. So in that context, is it possible to generate an infinite string of random numbers? Well, it is so long as you believe you can generate any amount random numbers at all. Just repeat the process, whatever it is.
Is that a reasonable thing to believe? That's probably a philosophical question at this point. I'm certainly not equipped to answer it. But assuming it is possible allows for some interesting math, which I support for its own sake.
This is all sort of reminiscent of a mathematician friend's stance on the axiom of choice. If you were to tell them a vehicle is only guaranteed to not explode by the axiom of choice, they wouldn't use it. On the other hand, assuming the axiom of choice is true leads to some useful math, even if it's sort of sketchy ontologically. It's a lot like programming. Sometimes you can't fix the bugs in the underlying system and you just code around them to get your stuff working.
Actually I had something even stronger in mind, being able to pass the generated number around. For pi I can have a program that I can pass around and that will give everyone access to all the digits of pi, in base 16 we can even have random access to all the digits.
For generating a random Cauchy sequence things are not that easy. Locally I can just use a true random number generator - in case such a thing exists - and generate all the digits I am interested in on demand, storing them in case I have to look at a previously generated digit again. But I can not easily pass that number around, only the digits I have already generated. We would need a shared database where everyone can share all the generated digits.
Or I could try to replace the true random number generator with a pseudo random number generator, then I could just pass the seed around. Everyone would have to either agree how the sequence of random numbers is mapped to the sequence of digits or we would have to use a seekable random number generator. But this raises the question whether using a [specific] pseudo random number generator would still yield a normal number.
ok... click
> Pi may be a normal number
huh...
We do not have, and perhaps will never get, proof that Pi is normal.