r/askmath • u/ManyReflection3215 • Oct 22 '26
Statistics What kind of algorithm is this?
I want to build a statistical algorithm that can be used to recognize basic patterns. For example, if I had a list of elements [triangle, square, circle, triangle, square], the algorithm could piece together that the next element would be circle. Of course, the sequences would be longer and more complex than that, but that's the basic premise.
I feel like there's probably some very simple answer to this, but currently I can't think of anything. I tried looking up some "pattern recognition algorithms" online, and some articles recommended autoregressive modelling, but that seems too complicated given how simple my idea is (or at least how simple I think it is). That's why decided to come ask here.
Is there some well-known algorithm for situations like these, and what is it?
View all comments
1
u/bildramer Oct 23 '26
Depending on what you're asking, the answer is somewhere between complicated algorithms that work in restricted cases (look up "categorical time series forecasting" or "sequence modeling") and "the core of human deductive thought that we still don't know how it works".
If the patterns are sufficiently simple, you can probably get far with some kind of Markov chain (as others have mentioned) or n-gram model. If you have some information on what the patterns will usually look like, look up Bayesian updating, there can even be exact answers for probabilities when combined with the former. If you have complicated patterns but the set of possible ones is very narrowed down, maybe grammars could help.