Anonymous user
Cumulative standard deviation: Difference between revisions
m
→show running sums: added/changed whitespace.
(→{{header|Perl}}: shorter perl version) |
m (→show running sums: added/changed whitespace.) |
||
Line 3,458:
<lang rexx>/*REXX program calculates and displays the standard deviation of a given set of numbers.*/
parse arg # /*obtain optional arguments from the CL*/
if #='' then #= 2 4 4 4 5 5 7 9
n= words(#);
/* [↓] process each number in the list*/
_= word(#, j); $= $ +
end /*j*/ /* [↑] prettify output with whitespace*/
say 'standard deviation: ' sqrt($$/n - ($/n)**2) /*calculate & display the std deviation*/
exit
/*──────────────────────────────────────────────────────────────────────────────────────*/
sqrt: procedure; parse arg x; if x=0 then return 0; d=digits(); h=d+6; m.=9; numeric form
|