procedure MOMENT(DATA:array of real; N:integer;var AVE, ADEV,
SDEV, VAR1, SKEW, CURT:real);
var
J:integer; S,P:real;
begin
If N begin
ShowMessage('N must be at least 2');
Exit;
end;
S:=0;
For J:=1 To N do
S:=S + DATA[J];
AVE:=S / N;
ADEV:=0;
VAR1:=0;
SKEW:=0;
CURT:=0;
For J:=1 To N do
begin
S:=DATA[J] - AVE;
ADEV:=ADEV + Abs(S);
P:=S * S;
VAR1:=VAR1 + P;
P:=P * S;
SKEW:=SKEW + P;
P:=P * S;
CURT:=CURT + P;
end;
ADEV:=ADEV / N;
VAR1:=VAR1 / (N - 1);
SDEV:=Sqrt(VAR1);
If VAR1 0 Then
begin
SKEW:=SKEW / (N * EXP(3*Ln(SDEV)));
CURT:=CURT / (N * VAR1*VAR1) - 3;
end
Else
ShowMessage('no skew or kurtosis when zero variance');
end;