[转]MATLAB中数据的标准化处理
(2012-04-13 12:43:04)
标签:
杂谈 |
分类: Matlab |
源地址 http://blog.163.com/jianghuchuan@126/blog/static/46094821201102411517509/
数据的标准化处理是指:使得数据的期望为0,方差为1。
zscore
比如:
B =
1 2 3 4 5 6
7 8 9 10 11 12
>> B_S=zscore(B)
B_S =
Columns 1 through 4
-0.7071 -0.7071 -0.7071 -0.7071
0.7071 0.7071 0.7071 0.7071
Columns 5 through 6
-0.7071 -0.7071
0.7071 0.7071
std(B) %标准差(方差的正的平方根)
ans =
Columns 1 through 4
4.2426 4.2426 4.2426 4.2426
Columns 5 through 6
4.2426 4.2426
var(B) %方差
ans =
18 18 18 18 18 18
>> B
B =
1 2 3 4 5 6
7 8 9 10 11 12
>> 4.2426*4.2426
ans =
17.9997
若要求整个矩阵所有元素的均方差,则要使用std2函数:
B =
1 2 3 4 5 6
7 8 9 10 11 12
>> std2(B)
ans =
3.6056
ZSCORE Standardized z score.
Z = ZSCORE(X) returns a centered, scaled version of X, the same size as X.
For vector input X, Z is the vector of z-scores (X-MEAN(X)) ./ STD(X). For
matrix X, z-scores are computed using the mean and standard deviation
along each column of X. For higher-dimensional arrays, z-scores are
computed using the mean and standard deviation along the first
non-singleton dimension.
The columns of Z have sample mean zero and sample standard deviation one
(unless a column of X is constant, in which case that column of Z is
constant at 0).
[Z,MU,SIGMA] = ZSCORE(X) also returns MEAN(X) in MU and STD(X) in SIGMA.
[...] = ZSCORE(X,1) normalizes X using STD(X,1), i.e., by computing the
standard deviation(s) using N rather than N-1, where N is the length of %这个很重要(无偏估计问题!!)
the dimension along which ZSCORE works. ZSCORE(X,0) is the same as
ZSCORE(X).
[...] = ZSCORE(X,FLAG,DIM) standardizes X by working along the dimension
DIM of X. Pass in FLAG==0 to use the default normalization by N-1, or 1
to use N.
前一篇:【转】使用matlab做回归分析
后一篇:【转】百度知道关于求相关系数

加载中…