
- Forum
- Programming Talk
- C and C++
- c++ code for the exponential smoothing formula in forcasting.
c++ code for the exponential smoothing formula in forcasting.
This is a discussion on c++ code for the exponential smoothing formula in forcasting. within the C and C++ forums, part of the Programming Talk category; //appiah-nketia akosua //exponential smoothing formula in forecasting methods //ucc ghana #include<iostream> #include<cmath> using namespace std; int t=0; double alpha=0; int ...
-
c++ code for the exponential smoothing formula in forcasting.
//appiah-nketia akosua
//exponential smoothing formula in forecasting methods
//ucc ghana
#include<iostream>
#include<cmath>
using namespace std;
int t=0;
double alpha=0;
int numofperiod;
double result;
double formula(double alpha,int a,int f );
void main()
{
cout<<"how many periods do you want to calculate the forecast for: "<<endl;
cin>>numofperiod;
if (numofperiod>1000){
cout<<"enter a smaller number"<<endl;
cin>>numofperiod;
}
double forecast[1000]; //array for forecast and actual values
double actualv[1000];
cout<<"please enter the value of alpha "<<endl;
cin>>alpha;//accepting the alpha value(between 0 and 1) from the user
for (int i=1; i<=numofperiod; i++)
{
cout<<"please enter the values of a "<<endl;
//accepting actual data from user
cin>>actualv[i-1];
}
forecast[0]=actualv[0]; //putting initial actual value in initial forecasted vale
for (int i=1;i<=numofperiod;i++)
{
forecast[i]=(alpha*actualv[i-1]+(1-alpha)*forecast[i-1]);
cout<<"your forecast values are: "<<forecast[i]<<endl;
}
//putting subsequent final answers in forecast values
}
Last edited by admin; 07-27-2011 at 09:07 AM.
-
Hi......
Thanks for this very helpful and innovative information in this site,,, i really appreciate. Keep it up.
I like this valuable information*these are very good tips for me .....
regards....
kumkum
-
08-13-2011, 05:53 AM #3
- Join Date
- Aug 2011
- Answers
- 2
good program but cant understand
-
08-23-2011, 02:41 AM #4
- Join Date
- Aug 2011
- Location
- Hyderabad
- Answers
- 22
Very informative. Please keep on posting such great posts so that every body will get good support from it.
-
Sponsored Ads

Reply With Quote





