I see basically two more or less simple ways to solve this problem: least squares method and maximum likelihood:
Maximum Likelihood
One approach to your problem is to consider temperature as a random variable
t
:
t ~ T(x, k)
That is, t
is random variable with distribution T
and parameters k
, being x
time.
t
is what you want to predict, x
is the time that would be tempo atual + 30 minutos
, and k
is a set of 1 or more unknown parameters of your distribution.
Looking at a sample of temperature values versus time, you can do a cursory analysis of how values behave and then choose their T
distribution function. There are many distributions, and the most common are: uniform, Poisson, exponential, binomial, Bernoulli, Beta, Gamma. Each one is best suited for a specific case (it would be an article to describe each of them!).
Once the distribution is chosen, you have to define the distribution parameters (each distribution requires different parameters). To obtain these parameters the simplest method is Maximum Likelihood (MVS), but Bayes could be used as well.
I recommend that you use a statistical book to understand the method, or a library that already implements it ready (I do not know of any to indicate).
Least Squares Methods
Generally taught in the disciplines of Numerical Methods or Numerical Calculus in higher engineering courses, it consists in observing the behavior of the values in a graph (in the case of temperature with time) and visually identifying a behavior to construct a function any, which may be first degree, or second or any other (including not necessarily a polynomial).
Assuming a function of the first degree, we can say that:
t = aX + E
Being t
the observed value, X
the time of the observed value, a
unknown coefficient and E
the error. That is, we are approaching the value observed by a function of the first degree plus the error.
Our goal is then to find% w / o of% that minimizes the sum of the quadratic errors in each sample value. That is:
t - aX = 0
By deriving and equaling a
and solving the formed system, you can find the value of 0
. It is then necessary to derive the function again to identify whether a
is the minimum or maximum point.
I believe these are the simplest methods to solve the problem, but there must be others (I'm not a mathematician). Certainly, many libraries already implement them, but I do not know them, since I only used these methods in university tests.
I hope I have helped!