A starting point could be Wikipedia's Time series[^] page.

13,667,657 members

Email

Password

Sign in with

See more:

Dear all,

I'd like to use time series analysis for predicting a future value i.e. energy consumption in simuator but i don't know how to do it in c++.Can anyone guide me or give me some example?

thanks

I'd like to use time series analysis for predicting a future value i.e. energy consumption in simuator but i don't know how to do it in c++.Can anyone guide me or give me some example?

thanks

Hi,

The best and faster way to do this is use a numeric software, like matlab.

if you want to implement it in c++, i advice you to use some existent forecast library.

You have a lot of models to forecast, such as auto regressive models (AR, ARX, ARMA, ARMAX, ARIMA, ...), fuzzy models, neural networks models, support vector machines models, markov chains, and so on...

This is just a simple model:

y(k)+a1y(k-1)+a2y(k-2)+...+any(k-n) = b1u(k)+b2u(k-1)+...+bmu(k-m)

Where y is your output and u is your input. 'a' and 'b' are coefficients that you can calculate them by minimizing some cost function.

Here is a example in c++ to calculate the future value (i did not tested it, there may be errors)

Again, I suggest to use some numerical software that brings such algorithms implemented.

Otherwise, google is the best way to start

Best regards

Filipe Marques

The best and faster way to do this is use a numeric software, like matlab.

if you want to implement it in c++, i advice you to use some existent forecast library.

You have a lot of models to forecast, such as auto regressive models (AR, ARX, ARMA, ARMAX, ARIMA, ...), fuzzy models, neural networks models, support vector machines models, markov chains, and so on...

This is just a simple model:

y(k)+a1y(k-1)+a2y(k-2)+...+any(k-n) = b1u(k)+b2u(k-1)+...+bmu(k-m)

Where y is your output and u is your input. 'a' and 'b' are coefficients that you can calculate them by minimizing some cost function.

Here is a example in c++ to calculate the future value (i did not tested it, there may be errors)

```
double forecast(double *y, double *u, bouble *a, double b)
{
double future_value = 0.0;
//y to the instant k
future_value = b[0]*u[0]+b[1]*u[1]+...+b[m-1]*u[m-1]-a[0]*y[0]+a[1]*y[1]+...+a[n-1]*y[n-1];
for(int i = 1; i < n; i++)
{
y[i] = y[i-1];
}
y[0] = future_value ;
//I assume that the input array is updated before you call this function
}
```

Again, I suggest to use some numerical software that brings such algorithms implemented.

Otherwise, google is the best way to start

Best regards

Filipe Marques

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise |
Privacy |
Cookies |
Terms of Service

Web01-2016 | 2.8.180820.1 | Last Updated 29 Mar 2012

Web01-2016 | 2.8.180820.1 | Last Updated 29 Mar 2012

Copyright © CodeProject, 1999-2018

All Rights Reserved.

All Rights Reserved.

CodeProject,
503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada
+1 416-849-8900 x 100