Mercurial > hg > octave-lyh
diff scripts/statistics/base/std.m @ 9500:bb37822e9b82
std.m: correctly work along singleton dimension
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 06 Aug 2009 14:28:56 -0400 |
parents | f0c3d3fc4903 |
children | be55736a0783 |
line wrap: on
line diff
--- a/scripts/statistics/base/std.m +++ b/scripts/statistics/base/std.m @@ -64,7 +64,7 @@ if (nargin < 1 || nargin > 3) print_usage (); endif - if nargin < 3 + if (nargin < 3) dim = find (size (a) > 1, 1); if (isempty (dim)) dim = 1; @@ -76,7 +76,7 @@ n = size (a, dim); if (n == 1) - retval = zeros (sz); + retval = zeros (size (a)); elseif (numel (a) > 0) retval = sqrt (sumsq (center (a, dim), dim) / (n + opt - 1)); else @@ -89,8 +89,9 @@ %! x = ones (10, 2); %! y = [1, 3]; %! assert(std (x) == [0, 0] && abs (std (y) - sqrt (2)) < sqrt (eps)); +%! assert (std (x, 0, 3), zeros (10, 2)) +%! assert (std (ones (3, 1, 2), 0, 2), zeros (3, 1, 2)) %!error std (); %!error std (1, 2, 3, 4); -