It depends on the behavior of the object that you are measuring. Is it something that moves (or changes) in a way that can be modeled?
If the element is not changed, then your trend should be the main average value of the entire set of patterns, and not just the last two measurements. You can get this using Bayes theorem. The average value can be calculated using a simple formula
Mtn1 = (Mtn * N + x) / (N + 1)
where x is the measurement at time t + 1, Mtn1 is the average time t + 1, Mtn is the average at time t, and N is the number of measurements taken by time t.
If the element you are measuring changes in a way that can be predicted by some basic equation, then you can use the Kalman filter to provide the best estimate of the next point based on previous (recent) measurements and an equation that simulates predicted behavior.
As a starting point, a Wikipedia entry on Bayesian estimates and Kalman filters will be useful.
source share