数据标准化方法z-score讲解(matlab)

 

在数据分析之前,我们通常需要先将数据标准化(normalization),利用标准化后的数据进行数据分析。

z-score 标准化(正太标准化)是基于原始数据的均值(mean)和标准差(standard deviation)进行数据的标准化。将A的原始值x使用z-score标准化到x’。

在matlab中,我们可以直接利用zscore(x)这个函数来将数据标准化。
其核心思想是:
z=(x-mean(x))./std(x)

当x是一个向量时,采用z方法得到的仍然是一个向量。例如下面:

>> a=[1,2,3]

a =

     1     2     3

>> b=zscore(a)

b =

    -1     0     1

>> 
  •  

当X是一个矩阵是,采用zscore方法仍然是一个矩阵,在计算的过程中使用的均值及标准差使用的是每一列的均值与方差

>> a=[1,2,3;4,5,6]

a =

     1     2     3
     4     5     6

>> b=zscore(a)

b =

   -0.7071   -0.7071   -0.7071
    0.7071    0.7071    0.7071

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.

猜你喜欢

转载自blog.csdn.net/It_BeeCoder/article/details/84955886