program moments; uses Classes, math; function Compare(A, B : Pointer) : integer; begin if PDouble(A)^>PDouble(B)^ then Result := 1 else if PDouble(A)^<PDouble(B)^ Then Result:=-1 else Result:=0; end; var i, N, middle : integer; list : TList; median, mean, deviation, average_deviation, standard_deviation, variance, skew, kurtosis, sum: double; p: PDouble; begin list := TList.Create; While Not Eof(input) do begin new(p); Readln(p^); list.Add(p); end; N := list.Count; sum:=0.0; for i:=0 to N-1 do sum:=sum+PDouble(list.items[i])^; mean := sum / N; average_deviation:=0.0; variance:=0.0; skew:=0.0; kurtosis:=0.0; for i:=0 to N-1 do begin deviation:=PDouble(list.items[i])^ - mean; average_deviation:=average_deviation + Abs(deviation); variance:=variance+power(deviation,2); skew:=skew+power(deviation,3); kurtosis:=kurtosis+power(deviation,4); end; average_deviation := average_deviation / N; variance := variance / (N-1); standard_deviation := Sqrt(variance); if variance<>0 then begin skew := skew / (N * variance * standard_deviation); kurtosis := kurtosis / (N * variance * variance ) - 3.0; end; list.Sort(Compare); middle := N Div 2; if (N Mod 2) <> 0 then median:=PDouble(list.items[middle])^ else median:=(PDouble(list.items[middle])^+PDouble(list.items[middle-1])^)*0.5; WriteLn('n: ', N); WriteLn('median: ', median:6:6); WriteLn('mean: ', mean:6:6); WriteLn('average_deviation: ', average_deviation:6:6); WriteLn('standard_deviation: ', standard_deviation:6:6); WriteLn('variance: ', variance:6:6); WriteLn('skew: ', skew:6:6); WriteLn('kurtosis: ', kurtosis:6:6); end.