comparison toolboxes/FullBNT-1.0.7/KPMstats/standardize.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function [S, mu, sigma2] = standardize(M, mu, sigma2)
2 % function S = standardize(M, mu, sigma2)
3 % Make each column of M be zero mean, std 1.
4 % Thus each row is scaled separately.
5 %
6 % If mu, sigma2 are omitted, they are computed from M
7
8 M = double(M);
9 if nargin < 2
10 mu = mean(M,2);
11 sigma2 = std(M,0,2);
12 sigma2 = sigma2 + eps*(sigma2==0);
13 end
14
15 [nrows ncols] = size(M);
16 S = M - repmat(mu(:), [1 ncols]);
17 S = S ./ repmat(sigma2, [1 ncols]);
18