ich war zu faul den ersten Post mit Fleisch zu versehen, ich meine 1/7 müsste passen
Delphi-Quellcode:
Function TestStdDev(a: Array of Double): Double;
var
i: Integer;
MW: Double;
begin
MW := 0;
Result := 0;
for i := 0 to High(a) do MW := MW + a[i];
MW := MW / ( High(a) + 1);
for i := 0 to High(a) do Result := Result + Power(a[i] - MW, 2);
Result := SQRT(Result / High(a));
end;
procedure TForm2.Button1Click(Sender: TObject);
var
i: Integer;
begin
SetLength(a, 10);
for i := 0 to High(a) - 1 do
a[i] := Random(100);
Label1.Caption := FloatToStr(StdDev(a));
Label2.Caption := FloatToStr(TestStdDev(a));
end;