Mercurial > hg > octave-lyh
diff scripts/sparse/spstats.m @ 11587:c792872f8942
all script files: untabify and strip trailing whitespace
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:35:29 -0500 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
line wrap: on
line diff
--- a/scripts/sparse/spstats.m +++ b/scripts/sparse/spstats.m @@ -21,12 +21,12 @@ ## @deftypefnx {Function File} {[@var{count}, @var{mean}, @var{var}] =} spstats (@var{S}, @var{j}) ## Return the stats for the non-zero elements of the sparse matrix @var{S}. ## @var{count} is the number of non-zeros in each column, @var{mean} -## is the mean of the non-zeros in each column, and @var{var} is the +## is the mean of the non-zeros in each column, and @var{var} is the ## variance of the non-zeros in each column. ## ## Called with two input arguments, if @var{S} is the data and @var{j} -## is the bin number for the data, compute the stats for each bin. In -## this case, bins can contain data values of zero, whereas with +## is the bin number for the data, compute the stats for each bin. In +## this case, bins can contain data values of zero, whereas with ## @code{spstats (@var{S})} the zeros may disappear. ## @end deftypefn @@ -39,19 +39,19 @@ if (nargin == 1) [i, j, v] = find (S); else - v = S; + v = S; i = 1:length (v); S = sparse (i, j, v); - endif + endif [n, m] = size (S); count = sum (sparse (i, j, 1, n, m)); - if (nargout > 1) - mean = sum (S) ./ count; + if (nargout > 1) + mean = sum (S) ./ count; endif - if (nargout > 2) + if (nargout > 2) ## FIXME Variance with count = 0 or 1? - diff = S - sparse (i, j, mean(j), n, m); + diff = S - sparse (i, j, mean(j), n, m); var = sum (diff .* diff) ./ (count - 1); endif