# Algorithm for detecting a finite limit of time-series numbers

Is there a well known and proven algorithm to find the TOP (finite) limit of a set of points, which are time based metrics? I'm looking for an existing implementation, in order not to invent the wheel of something which already exists.

This is what I have in mind, but it is a bit hard to configure the right parameters, and requires iterations:

Run over the numeric values of a series

1. Calculate L which is the top limit, and E (E is configurable), where 2*E is the convergent stripe around L.
• Most points, P percentage, except of anomalies/noise, are below the top line of L+E (P is configurable, ranging somewhere at 95-99% range).
• A Linear line around the last X points (Linear Regression) has a minor slope of +/-S (X and S are configurable)
2. The algo uses a stored state of a previous maximum limit - max-L.
• In case L which was calculated in (a) is lower than max-L, it is considered a local max which is discarded
• If L is greater than max-L then it is considered a new max limit and stored as the new max-L

The question is do you know of an existing algorithm to fulfil this, or add any suggestions to the algorithm I created. Thanks!

NOTE: Just to be clear, as an input I have a set of data points, each with a real value and a timestamp. There is no function input, just those points. This mean, that the algorithm might detect a limit, which when inspecting all the historical data points would look like a true maximum limit, but then later in time new data points would be higher and yield a new higher limit. meaning that the algorithm I'm looking for would only find "local" limits.

• What is your input? Are you given a function, or do you only get a set of data-points? If the latter, I think you need to assume that the strip containing all values with $x>K$ for some $K$ is strictly decreasing in $K$, as otherwise the series can seemingly converge and then e.g. become strictly increasing at some time later. – Discrete lizard Apr 7 at 10:34
• thanks @Discretelizard the input is a set of data points, each with a real value and a timestamp. If I understand you comment correctly, I believe that at a single point in time it can get concluded that a limit was reached - taking into account all past data points, giving a local max limit. but then later on in the future it can happen that a new higher limit would reach. I don't see how this can get avoided, and therefore this is a limitation I can live with. again, finding a limit and then in the future understanding that it was not the real limit – ziv Apr 7 at 10:49
• Yes, you can only hope to find 'local' limits if you are given finite information about an infinite series. Please edit these points you address in the comment into your question to make it clearer. Thank you! – Discrete lizard Apr 7 at 10:56
• thanks again for the clarification @Discretelizard. I just updated the question – ziv Apr 7 at 11:08
• Have you looked at change point detection? – D.W. Apr 7 at 15:49