Exforsys
+ Reply to Thread
Results 1 to 4 of 4

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 ...

  1. #1
    loctovia is offline Junior Member Array
    Join Date
    Apr 2011
    Answers
    2

    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.

  2. #2
    kumkum01 is offline Junior Member Array
    Join Date
    Jun 2011
    Answers
    3
    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


  3. #3
    guptamahesh is offline Junior Member Array
    Join Date
    Aug 2011
    Answers
    2
    good program but cant understand


  4. #4
    poojadreams is offline Junior Member Array
    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



Latest Article

Network Security Risk Assessment and Measurement

Read More...