Anonymous user
Cumulative standard deviation: Difference between revisions
m
→only show standard deviation: added/changed whitespace and comments.
m (→show running sums: added/changed whitespace.) |
m (→only show standard deviation: added/changed whitespace and comments.) |
||
Line 3,491:
<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(#); $= 0;
/* [↓] process each number in the list*/
do j=1 for n
_= word(#,
$$= $$ + _**2
end /*j*/
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
|