Jump to content

Cumulative standard deviation: Difference between revisions

→‎{{header|Delphi}}: Corrected Program
m (→‎{{header|REXX}}: updated the SQRT function.)
(→‎{{header|Delphi}}: Corrected Program)
Line 972:
2.000000e+00</pre>
 
=={{header|DelphiPascal}}==
==={{header|Delphi}}===
{{incorrect|Delphi|It does not return the ''running'' standard deviation of the series. or take numbers individually.}}
<lang Delphi>program StdDevTestprj_CalcStdDerv;
Delphi has 2 functions in Math unit for standard deviation: ''StdDev'' (with Bessel correction) and ''PopnStdDev'' (without Bessel correction). The task assumes the second function:
 
<lang Delphi>program StdDevTest;
 
{$APPTYPE CONSOLE}
Line 983 ⟶ 981:
Math;
 
var Series:Array of Extended;
UserString:String;
 
 
function AppendAndCalc(NewVal:Extended):Extended;
 
begin
setlength(Series,high(Series)+2);
Series[high(Series)] := NewVal;
result := PopnStdDev(Series);
end;
 
const data:array[0..7] of Extended =
Writeln(PopnStdDev([2,4,4,4,5,5,7,9]));
 
var rr: Extended;
begin
setlength(Series,0);
Writeln(PopnStdDev([2,4,4,4,5,5,7,9]));
for rr in data do
begin
writeln(rr,' -> ',AppendAndCalc(rr));
end;
Readln;
end. </lang>
Output:
<pre>
2.0000000000000000E+0000 -> 0.0000000000000000E+0000
4.0000000000000000E+0000 -> 1.0000000000000000E+0000
4.0000000000000000E+0000 -> 9.4280904158206337E-0001
4.0000000000000000E+0000 -> 8.6602540378443865E-0001
5.0000000000000000E+0000 -> 9.7979589711327124E-0001
5.0000000000000000E+0000 -> 1.0000000000000000E+0000
7.0000000000000000E+0000 -> 1.3997084244475303E+0000
9.0000000000000000E+0000 -> 2.0000000000000000E+0000
</pre>
 
=={{header|E}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.