Mercurial > hg > octave-terminal
changeset 1723:ab9a2880b6c5
[project @ 1996-01-09 06:12:13 by jwe]
author | jwe |
---|---|
date | Tue, 09 Jan 1996 06:12:13 +0000 |
parents | d6c9a1db3f6b |
children | a45e88743238 |
files | scripts/statistics/std.m |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/statistics/std.m +++ b/scripts/statistics/std.m @@ -35,14 +35,14 @@ if (nc == 1 && nr == 1) retval = 0; elseif (nc == 1 || nr == 1) - tmp = sum (a); n = length (a); - retval = sqrt ((n * sumsq (a) - tmp .* tmp) / (n * (n - 1))); + retval = sqrt (sumsq (a - mean (a)) / (n - 1)); elseif (nr > 1 && nc > 0) - tmp = sum (a); - retval = sqrt ((nr * sumsq (a) - tmp .* tmp) / (nr * (nr - 1))); + tmp = mean (a); + tmp = tmp (ones (nr, 1), :); + retval = sqrt (sumsq (a - tmp) / (nr - 1)); else - error ("mean: invalid matrix argument"); + error ("std: invalid matrix argument"); endif endfunction