OR-Notes

J E Beasley

OR-Notes are a series of introductory notes on topics that fall under the broad heading of the field of operations research (OR). They were originally used by me in an introductory OR course I give at Imperial College. They are now available for use by any students and teachers interested in OR subject to the following conditions.

A full list of the topics available in OR-Notes can be found here.


Forecasting examples

Forecasting example 1996 UG exam

The demand for a product in each of the last five months is shown below.

Month         1  2  3  4  5
Demand ('00s) 13 17 19 23 24 
  • Use a two month moving average to generate a forecast for demand in month 6.
  • Apply exponential smoothing with a smoothing constant of 0.9 to generate a forecast for demand for demand in month 6.
  • Which of these two forecasts do you prefer and why?
  • Solution

    The two month moving average for months two to five is given by:

    m2 = (13 + 17)/2 = 15.0
    m3 = (17 + 19)/2 = 18.0
    m4 = (19 + 23)/2 = 21.0
    m5 = (23 + 24)/2 = 23.5

    The forecast for month six is just the moving average for the month before that i.e. the moving average for month 5= m5 = 2350.

    Applying exponential smoothing with a smoothing constant of 0.9 we get:

    M1 = Y1 = 13
    M2 = 0.9Y2 + 0.1M1 = 0.9(17) + 0.1(13) = 16.60
    M3 = 0.9Y3 + 0.1M2 = 0.9(19) + 0.1(16.60) = 18.76
    M4 = 0.9Y4 + 0.1M3 = 0.9(23) + 0.1(18.76) = 22.58
    M5 = 0.9Y5 + 0.1M4 = 0.9(24) + 0.1(22.58) = 23.86

    As before the forecast for month six is just the average for month 5= M5 = 2386

    To compare the two forecasts we calculate the mean squared deviation (MSD). If we do this we find that for the moving average

    and for the exponentially smoothed average with a smoothing constant of 0.9

    Overall then we see that exponential smoothing appears to give the best one month ahead forecasts as it has a lower MSD. Hence we prefer the forecast of 2386 that has been produced by exponential smoothing.


    Forecasting example 1994 UG exam

    The table below shows the demand for a new aftershave in a shop for each of the last 7 months.

    Month   1  2  3  4  5  6  7
    Demand  23 29 33 40 41 43 49
    

    Solution

    The two month moving average for months two to seven is given by:

    m2 = (23 + 29)/2 = 26.0
    m3 = (29 + 33)/2 = 31.0
    m4 = (33 + 40)/2 = 36.5
    m5 = (40 + 41)/2 = 40.5
    m6 = (41 + 43)/2 = 42.0
    m7 = (43 + 49)/2 = 46.0

    The forecast for month eight is just the moving average for the month before that i.e. the moving average for month 7 = m7 = 46.

    Applying exponential smoothing with a smoothing constant of 0.1 we get:

    M1 = Y1 = 23
    M2 = 0.1Y2 + 0.9M1 = 0.1(29) + 0.9(23) = 23.60
    M3 = 0.1Y3 + 0.9M2 = 0.1(33) + 0.9(23.60) = 24.54
    M4 = 0.1Y4 + 0.9M3 = 0.1(40) + 0.9(24.54) = 26.09
    M5 = 0.1Y5 + 0.9M4 = 0.1(41) + 0.9(26.09) = 27.58
    M6 = 0.1Y6 + 0.9M5 = 0.1(43) + 0.9(27.58) = 29.12
    M7 = 0.1Y7 + 0.9M6 = 0.1(49) + 0.9(29.12) = 31.11

    As before the forecast for month eight is just the average for month 7 = M7 = 31.11 = 31 (as we cannot have fractional demand).

    To compare the two forecasts we calculate the mean squared deviation (MSD). If we do this we find that for the moving average

    and for the exponentially smoothed average with a smoothing constant of 0.1

    Overall then we see that the two month moving average appears to give the best one month ahead forecasts as it has a lower MSD. Hence we prefer the forecast of 46 that has been produced by the two month moving average.

    To examine switching we would need to use a Markov process model, where states = brands and we would need initial state information and customer switching probabilities (from surveys). We would need to run the model on historical data to see if we have a fit between the model and historical behaviour.


    Forecasting example 1992 UG exam

    The table below shows the demand for a particular brand of razor in a shop for each of the last nine months.

    Month   1  2  3  4  5  6  7  8  9
    Demand  10 12 13 17 15 19 20 21 20
    

    Solution

    The three month moving average for months 3 to 9 is given by:

    m3 = (10 + 12 + 13)/3 = 11.67
    m4 = (12 + 13 + 17)/3 = 14.00
    m5 = (13 + 17 + 15)/3 = 15.00
    m6 = (17 + 15 + 19)/3 = 17.00
    m7 = (15 + 19 + 20)/3 = 18.00
    m8 = (19 + 20 + 21)/3 = 20.00
    m9 = (20 + 21 + 20)/3 = 20.33

    The forecast for month 10 is just the moving average for the month before that i.e. the moving average for month 9 = m9 = 20.33.

    Hence (as we cannot have fractional demand) the forecast for month 10 is 20.

    Applying exponential smoothing with a smoothing constant of 0.3 we get:

    M1 = Y1 = 10
    M2 = 0.3Y2 + 0.7M1 = 0.3(12) + 0.7(10) = 10.60
    M3 = 0.3Y3 + 0.7M2 = 0.3(13) + 0.7(10.60) = 11.32
    M4 = 0.3Y4 + 0.7M3 = 0.3(17) + 0.7(11.32) = 13.02
    M5 = 0.3Y5 + 0.7M4 = 0.3(15) + 0.7(13.02) = 13.61
    M6 = 0.3Y6 + 0.7M5 = 0.3(19) + 0.7(13.61) = 15.23
    M7 = 0.3Y7 + 0.7M6 = 0.3(20) + 0.7(15.23) = 16.66
    M8 = 0.3Y8 + 0.7M7 = 0.3(21) + 0.7(16.66) = 17.96
    M9 = 0.3Y9 + 0.7M8 = 0.3(20) + 0.7(17.96) = 18.57

    As before the forecast for month 10 is just the average for month 9 = M9 = 18.57 = 19 (as we cannot have fractional demand).

    To compare the two forecasts we calculate the mean squared deviation (MSD). If we do this we find that for the moving average

    and for the exponentially smoothed average with a smoothing constant of 0.3

    Overall then we see that the three month moving average appears to give the best one month ahead forecasts as it has a lower MSD. Hence we prefer the forecast of 20 that has been produced by the three month moving average.


    Forecasting example 1991 UG exam

    The table below shows the demand for a particular brand of fax machine in a department store in each of the last twelve months.

    Month    1  2  3  4  5  6  7  8  9  10 11 12
    Demand   12 15 19 23 27 30 32 33 37 41 49 58
    

    Solution

    The four month moving average for months 4 to 12 is given by:

    m4 = (23 + 19 + 15 + 12)/4 = 17.25
    m5 = (27 + 23 + 19 + 15)/4 = 21
    m6 = (30 + 27 + 23 + 19)/4 = 24.75
    m7 = (32 + 30 + 27 + 23)/4 = 28
    m8 = (33 + 32 + 30 + 27)/4 = 30.5
    m9 = (37 + 33 + 32 + 30)/4 = 33
    m10 = (41 + 37 + 33 + 32)/4 = 35.75
    m11 = (49 + 41 + 37 + 33)/4 = 40
    m12 = (58 + 49 + 41 + 37)/4 = 46.25

    The forecast for month 13 is just the moving average for the month before that i.e. the moving average for month 12 = m12 = 46.25.

    Hence (as we cannot have fractional demand) the forecast for month 13 is 46.

    Applying exponential smoothing with a smoothing constant of 0.2 we get:

    M1 = Y1 = 12
    M2 = 0.2Y2 + 0.8M1 = 0.2(15) + 0.8(12) = 12.600
    M3 = 0.2Y3 + 0.8M2 = 0.2(19) + 0.8(12.600) = 13.880
    M4 = 0.2Y4 + 0.8M3 = 0.2(23) + 0.8(13.880) = 15.704
    M5 = 0.2Y5 + 0.8M4 = 0.2(27) + 0.8(15.704) = 17.963
    M6 = 0.2Y6 + 0.8M5 = 0.2(30) + 0.8(17.963) = 20.370
    M7 = 0.2Y7 + 0.8M6 = 0.2(32) + 0.8(20.370) = 22.696
    M8 = 0.2Y8 + 0.8M7 = 0.2(33) + 0.8(22.696) = 24.757
    M9 = 0.2Y9 + 0.8M8 = 0.2(37) + 0.8(24.757) = 27.206
    M10 = 0.2Y10 + 0.8M9 = 0.2(41) + 0.8(27.206) = 29.965
    M11 = 0.2Y11 + 0.8M10 = 0.2(49) + 0.8(29.965) = 33.772
    M12 = 0.2Y12 + 0.8M11 = 0.2(58) + 0.8(33.772) = 38.618

    As before the forecast for month 13 is just the average for month 12 = M12 = 38.618 = 39 (as we cannot have fractional demand).

    To compare the two forecasts we calculate the mean squared deviation (MSD). If we do this we find that for the moving average

    and for the exponentially smoothed average with a smoothing constant of 0.2

    Overall then we see that the four month moving average appears to give the best one month ahead forecasts as it has a lower MSD. Hence we prefer the forecast of 46 that has been produced by the four month moving average.

    Other factors:


    Forecasting example 1989 UG exam

    The table below shows the demand for a particular brand of microwave oven in a department store in each of the last twelve months.

    Month   1  2  3  4  5  6  7  8  9  10 11 12
    Demand  27 31 29 30 32 34 36 35 37 39 40 42
    

    Solution

    Now we cannot calculate a six month moving average until we have at least 6 observations - i.e. we can only calculate such an average from month 6 onward. Hence we have:

    m6 = (34 + 32 + 30 + 29 + 31 + 27)/6 = 30.50

    m7 = (36 + 34 + 32 + 30 + 29 + 31)/6 = 32.00

    m8 = (35 + 36 + 34 + 32 + 30 + 29)/6 = 32.67

    m9 = (37 + 35 + 36 + 34 + 32 + 30)/6 = 34.00

    m10 = (39 + 37 + 35 + 36 + 34 + 32)/6 = 35.50

    m11 = (40 + 39 + 37 + 35 + 36 + 34)/6 = 36.83

    m12 = (42 + 40 + 39 + 37 + 35 + 36)/6 = 38.17

    The forecast for month 13 is just the moving average for the month before that i.e. the moving average for month 12 = m12 = 38.17.

    Hence (as we cannot have fractional demand) the forecast for month 13 is 38.

    Applying exponential smoothing with a smoothing constant of 0.7 we get:

    M1 = Y1 = 27

    M2 = 0.7Y2 + 0.3M1 = 0.7(31) + 0.3(27) = 29.80

    M3 = 0.7Y3 + 0.3M2 = 0.7(29) + 0.3(29.80) = 29.24

    M4 = 0.7Y4 + 0.3M3 = 0.7(30) + 0.3(29.24) = 29.77

    M5 = 0.7Y5 + 0.3M4 = 0.7(32) + 0.3(29.77) = 31.33

    M6 = 0.7Y6 + 0.3M5 = 0.7(34) + 0.3(31.33) = 33.20

    M7 = 0.7Y7 + 0.3M6 = 0.7(36) + 0.3(33.20) = 35.16

    M8 = 0.7Y8 + 0.3M7 = 0.7(35) + 0.3(35.16) = 35.05

    M9 = 0.7Y9 + 0.3M8 = 0.7(37) + 0.3(35.05) = 36.42

    M10 = 0.7Y10 + 0.3M9 = 0.7(39) + 0.3(36.42) = 38.23

    M11 = 0.7Y11 + 0.3M10 = 0.7(40) + 0.3(38.23) = 39.47

    M12 = 0.7Y12 + 0.3M11 = 0.7(42) + 0.3(39.47) = 41.24

    As before the forecast for month 13 is just the average for month 12 = M12 = 41.24 = 41 (as we cannot have fractional demand).

    To compare the two forecasts we calculate the mean squared deviation (MSD). If we do this we find that for the moving average

    and for the exponentially smoothed average with a smoothing constant of 0.7

    a smoothing constant of 0.7 appears to give the best one month ahead forecasts as it has a lower MSD. Hence we prefer the forecast of 41 that has been produced by exponential smoothing with a smoothing constant of 0.7.


    Forecasting example 1987 UG exam

    The table below shows the temperature (degrees C), at 11 p.m., over the last ten days:

    Day         1   2   3   4   5    6    7    8    9   10
    Temperature 1.5 2.3 3.7 3.0 1.4 -1.3 -2.4 -3.7 -0.5 1.3
    

    Solution

    Now we cannot calculate a 3 day moving average until we have at least 3 observations i.e. we can only calculate such an average from month 3 onward. Hence we have:

    m3 = (1.5 + 2.3 + 3.7)/3 = 2.50

    m4 = (2.3 + 3.7 + 3.0)/3 = 3.00

    m5 = (3.7 + 3.0 + 1.4)/3 = 2.70

    m6 = (3.0 + 1.4 - 1.3)/3 = 1.03

    m7 = (1.4 - 1.3 - 2.4)/3 = -0.77

    m8 = (-1.3 - 2.4 - 3.7)/3 = -2.47

    m9 = (-2.4 - 3.7 - 0.5)/3 = -2.20

    m10 = (-3.7 - 0.5 + 1.3)/3 = -0.97

    Hence the forecast for the temperature at 11 p.m. on day 11 is just m10 = -0.97.

    Applying exponential smoothing with a smoothing constant of 0.8 we get:

    M1 = Y1 = 1.5

    M2 = 0.8Y2 + 0.2M1 = 0.8(2.3) + 0.2(1.5) = 2.14

    M3 = 0.8Y3 + 0.2M2 = 0.8(3.7) + 0.2(2.14) = 3.39

    M4 = 0.8Y4 + 0.2M3 = 0.8(3.0) + 0.2(3.39) = 3.08

    M5 = 0.8Y5 + 0.2M4 = 0.8(1.4) + 0.2(3.08) = 1.74

    M6 = 0.8Y6 + 0.2M5 = 0.8(-1.3) + 0.2(1.74) = -0.69

    M7 = 0.8Y7 + 0.2M6 = 0.8(-2.4) + 0.2(-0.69) = -2.06

    M8 = 0.8Y8 + 0.2M7 = 0.8(-3.7) + 0.2(-2.06) = -3.37

    M9 = 0.8Y9 + 0.2M8 = 0.8(-0.5) + 0.2(-3.37) = -1.07

    M10 = 0.8Y10 + 0.2M9 = 0.8(1.3) + 0.2(-1.07) = 0.83

    Hence the forecast for the temperature at 11 p.m. on day 11 is just M10 = 0.83.

    To compare the two forecasts we calculate the mean squared deviation (MSD). If we do this we find that for the moving average MSD=7.90 and for the exponentially smoothed average with a smoothing constant of 0.8 MSD=3.86.

    Hence overall prefer the exponentially smoothed forecast as that seems to give the best one day ahead forecasts as it has a smaller MSD.


    Forecasting example 1985 UG exam

    The table below shows the sales of a toy robot over the last 11 months.

    Month  1    2    3    4    5    6    7    8    9    10   11
    Sales  3651 4015 3874 3501 3307 3105 2986 3100 3209 3450 3507
    

    Solution

    Now we cannot calculate a 4 month moving average until we have at least 4 observations - i.e. we can only calculate such an average from month 4 onward. Hence we have:

    m4 = (3651 + 4015 + 3874 + 3501)/4 = 3760.25

    m5 = (4015 + 3874 + 3501 + 3307)/4 = 3674.25

    m6 = (3874 + 3501 + 3307 + 3105)/4 = 3446.75

    m7 = (3501 + 3307 + 3105 + 2986)/4 = 3224.75

    m8 = (3307 + 3105 + 2986 + 3100)/4 = 3124.50

    m9 = (3105 + 2986 + 3100 + 3209)/4 = 3100.00

    m10 = (2986 + 3100 + 3209 + 3450)/4 = 3186.25

    m11 = (3100 + 3209 + 3450 + 3507)/4 = 3316.50

    The forecast for month 12 is just the moving average for the month before that i.e. the moving average for month 11 = m11 = 3316.50

    Applying exponential smoothing with a smoothing constant of 0.9 we get:

    M1 = Y1 = 3651

    M2 = 0.9Y2 + 0.1M1 = 0.9(4015) + 0.1(3651) = 3978.60

    M3 = 0.9Y3 + 0.1M2 = 0.9(3874) + 0.1(3978.60) = 3884.46

    M4 = 0.9Y4 + 0.1M3 = 0.9(3501) + 0.1(3884.46) = 3539.35

    M5 = 0.9Y5 + 0.1M4 = 0.9(3307) + 0.1(3539.35) = 3330.24

    M6 = 0.9Y6 + 0.1M5 = 0.9(3105) + 0.1(3330.24) = 3127.52

    M7 = 0.9Y7 + 0.1M6 = 0.9(2986) + 0.1(3127.52) = 3000.15

    M8 = 0.9Y8 + 0.1M7 = 0.9(3100) + 0.1(3000.15) = 3090.02

    M9 = 0.9Y9 + 0.1M8 = 0.9(3209) + 0.1(3090.02) = 3197.10

    M10= 0.9Y10 + 0.1M9 = 0.9(3450) + 0.1(3197.10) = 3424.71

    M11 = 0.9Y11 + 0.1M10 = 0.9(3507) + 0.1(3424.71) = 3498.77

    As before the forecast for month 12 is just the average for month 11 = M11 = 3498.77.

    To compare the two forecasts we calculate the mean squared deviation (MSD). If we do this we find that for the moving average

    and for the exponentially smoothed average with a smoothing constant of 0.9

    Overall then we see that exponential smoothing with a smoothing constant of 0.9 appears to give the best one month ahead forecasts as it has a lower MSD. Hence we prefer the forecast of 3498.77 that has been produced by exponential smoothing with a smoothing constant of 0.9.


    Forecasting example

    The table below shows the movement of the price of a commodity over 12 months.

    Month  1  2  3  4  5  6  7  8  9  10 11 12 
    Price  25 30 32 33 32 31 30 29 28 28 29 31 

    Solution

    Now we cannot calculate a 6 month moving average until we have at least 6 observations - i.e. we can only calculate such an average from month 6 onward. Hence we have:

    m6 = (25 + 30 + 32 + 33 + 32 + 31)/6 = 30.50

    m7 = (30 + 32 + 33 + 32 + 31 + 30)/6 = 31.33

    m8 = (32 + 33 + 32 + 31 + 30 + 29)/6 = 31.17

    m9 = (33 + 32 + 31 + 30 + 29 + 28)/6 = 30.50

    m10 = (32 + 31 + 30 + 29 + 28 + 28)/6 = 29.67

    m11 = (31 + 30 + 29 + 28 + 28 + 29)/6 = 29.17

    m12 = (30 + 29 + 28 + 28 + 29 + 31)/6 = 29.17

    The forecast for month 13 is just the moving average for the month before that i.e. the moving average for month 12 = m12 = 29.17.

    Applying exponential smoothing with a smoothing constant of 0.7 we get:

    M1 = Y1 = 25

    M2 = 0.7Y2 + 0.3M1 = 0.7(30) + 0.3(25) = 28.50

    M3 = 0.7Y3 + 0.3M2 = 0.7(32) + 0.3(28.50) = 30.95

    M4 = 0.7Y4 + 0.3M3 = 0.7(33) + 0.3(30.95) = 32.39

    M5 = 0.7Y5 + 0.3M4 = 0.7(32) + 0.3(32.39) = 32.12

    M6 = 0.7Y6 + 0.3M5 = 0.7(31) + 0.3(32.12) = 31.34

    M7 = 0.7Y7 + 0.3M6 = 0.7(30) + 0.3(31.34) = 30.40

    M8 = 0.7Y8 + 0.3M7 = 0.7(29) + 0.3(30.40) = 29.42

    M9 = 0.7Y9 + 0.3M8 = 0.7(28) + 0.3(29.42) = 28.43

    M10 = 0.7Y10 + 0.3M9 = 0.7(28) + 0.3(28.43) = 28.13

    M11 = 0.7Y11 + 0.3M10 = 0.7(29) + 0.3(28.13) = 28.74

    M12 = 0.7Y12 + 0.3M11 = 0.7(31) + 0.3(28.74) = 30.32

    As before the forecast for month 13 is just the average for month 12 = M12 = 30.32.

    Applying exponential smoothing with a smoothing constant of 0.8 we get:

    M1 = Y1 = 25

    M2 = 0.8Y2 + 0.2M1 = 0.8(30) + 0.2(25) = 29.00

    M3 = 0.8Y3 + 0.2M2 = 0.8(32) + 0.2(29.00) = 31.40

    M4 = 0.8Y4 + 0.2M3 = 0.8(33) + 0.2(31.40) = 32.68

    M5 = 0.8Y5 + 0.2M4 = 0.8(32) + 0.2(32.68) = 32.14

    M6 = 0.8Y6 + 0.2M5 = 0.8(31) + 0.2(32.14) = 31.23

    M7 = 0.8Y7 + 0.2M6 = 0.8(30) + 0.2(31.23) = 30.25

    M8 = 0.8Y8 + 0.2M7 = 0.8(29) + 0.2(30.25) = 29.25

    M9 = 0.8Y9 + 0.2M8 = 0.8(28) + 0.2(29.25) = 28.25

    M10 = 0.8Y10 + 0.2M9 = 0.8(28) + 0.2(28.25) = 28.05

    M11 = 0.8Y11 + 0.2M10 = 0.8(29) + 0.2(28.05) = 28.81

    M12 = 0.8Y12 + 0.2M11 = 0.8(31) + 0.2(28.81) = 30.56

    As before the forecast for month 13 is just the average for month 12 = M12 = 30.56.

    To decide which of the two forecasts based on exponential smoothing we prefer we calculate the MSD for the two exponentially smoothed averages. The resulting figures represent the historical accuracy of the two forecasting procedures with respect to one month ahead forecasts. Knowing this accuracy tells us which of the two exponentially smoothed forecasts for month 13 we prefer.

    Performing the calculations we find that for exponential smoothing with a smoothing constant of 0.7 MSD=4.97 whilst for exponential smoothing with a smoothing constant of 0.8 MSD=4.43.

    Overall then we see that exponential smoothing with a smoothing constant of 0.8 appears to give the best one month ahead forecasts over the last 11 months. Hence we prefer the forecast of 30.56 for month 13 that has been produced by exponential smoothing with a smoothing constant of 0.8.