# Find incline of 50% within 30 minutes in a steadily increasing timeseries

I have a list of steadily growing values like 19:57(12.259), 19:58(13.101) stored in mongodb. Now I want to find out if the value grew 50% within 30 minutes within the last 3 hours.

My first naive approach was to take the value from 3 hours ago (a) and then look for the point in time when the value is greater than or equal (a*1.5). Then - in a post check - I test if this increase happened within 30 minutes.

This does work if the post condition is fulfilled but fails if it doesn't and there would be another, better candidate. In this case I would need to go on looking but there has to be a better way.

Basically I think, I am looking for a way to find a certain steepness on a curve.

• "Steepness of a curve" is called "slope." That's not quite enough to solve your particular problem, though. Commented Sep 12, 2017 at 22:19
• I can think of a naive O(n²) solution, where n is the number of data points that span a 30 minute window. Would that be sufficient? You start at k, check the points to y (where k and y are your 30 minute window, starting at k=0), to see if any of them exceed i[k] * 1.5. Then, increment k and y, and do it again until k equals the end. Commented Sep 12, 2017 at 22:25
• That would be my solution as well but with a resolution of 1 minute this is 180 potential results and this has to be checked for 190 individual time series. I can pull them all out of the database but I was hoping for some smart mathematical algorithm to apply then. Commented Sep 12, 2017 at 23:30
• Do you need to find a place where it increases exactly 50% or is more acceptable? And by within, do you mean that increase must be over the time of exactly 30 minutes, or are shorter intervals acceptable? Commented Sep 13, 2017 at 8:16
• The growth is measured from any point in time within a timeframe and it's never negative. It's max 30 minutes and 50% or more (>= a * 1.5) Commented Sep 13, 2017 at 9:12

I don't really understand why your solution doesn't work, logically it should. However, another option is to go back 3 hours and systematically compare the original point (`a`) to the point 30 minutes afterwards (`b`) to see if `b >= a * 1.5`, starting with the points 17:00 (or whatever 3 hours ago is) and 17:30. Then compare 17:01 and 17:31 and so on.