Sub MOMENT(DATA(), N, AVE, ADEV, SDEV, VAR, SKEW, CURT)
If N Print " 'N must be at least 2'"
Exit Sub
End If
S = 0#
For J = 1 To N
S = S + DATA(J)
Next J
AVE = S / N
ADEV = 0#
VAR = 0#
SKEW = 0#
CURT = 0#
For J = 1 To N
S = DATA(J) - AVE
ADEV = ADEV + Abs(S)
P = S * S
VAR = VAR + P
P = P * S
SKEW = SKEW + P
P = P * S
CURT = CURT + P
Next J
ADEV = ADEV / N
VAR = VAR / (N - 1)
SDEV = Sqr(VAR)
If VAR 0# Then
SKEW = SKEW / (N * SDEV ^ 3)
CURT = CURT / (N * VAR ^ 2) - 3#
Else
Print " no skew or kurtosis when zero variance"
End If
End Sub