程序代写代做代考 ”=======================================================

”=======================================================
” Developer Name:
” Register Number:
” Description: This program defines functions that are used in the
” project for Holt-Winters method forecasting seasonal data.

”=======================================================

‘ This function is used to compute the moving average
‘ It accepts an array data and return the moving average array

Function movingAverage(x As Variant) As Variant

Dim y As Variant

ReDim y(1 To 9, 1 To 1)

Dim i As Integer, j As Integer

Dim av As Double

For i = 1 To 9
av = 0
For j = 0 To 3
av = av + x(i + j)
Next j

av = av / 4

y(i, 1) = av
Next i

movingAverage = y

End Function

‘ This function is used to compute the trend
‘ It accepts mean moving average and mean difference as parameters
‘ and returns the trend: an array of number

Function computeTrend(ma As Double, diff As Double) As Variant

Dim y As Variant

ReDim y(1 To 12, 1 To 1)

Dim i As Integer

For i = 1 To 12
y(i, 1) = ma + (i – 6) * diff

Next i

computeTrend = y

End Function

‘ This function is used to compute a sequence with a start point and the difference of neighboring data
Function computeSequence(ma As Double, diff As Double) As Variant

Dim y As Variant

ReDim y(1 To 8, 1 To 1)

Dim i As Integer

For i = 1 To 8
y(i, 1) = ma + i * diff

Next i

computeSequence = y

End Function