为什么 np.std(X) 和 X.std() return 有不同的值?
Why do np.std(X) and X.std() return different values?
我正在尝试使用均值归一化为我的数据集计算归一化分数。当我写 (X - np.mean(X))/np.std(X)
时,它给我的分数与 ((X - X.mean())/X.std()
不同。
问题似乎出在标准偏差的计算上。 X.std()
returns 一个标准差值和 np.std()
returns 个不同的标准化值。为什么会这样?
Pandas uses the unbiased estimator (N-1 in the denominator), whereas
Numpy by default does not.
To make them behave the same, pass ddof=1
to numpy.std()
.
Different std in pandas vs numpy
我正在尝试使用均值归一化为我的数据集计算归一化分数。当我写 (X - np.mean(X))/np.std(X)
时,它给我的分数与 ((X - X.mean())/X.std()
不同。
问题似乎出在标准偏差的计算上。 X.std()
returns 一个标准差值和 np.std()
returns 个不同的标准化值。为什么会这样?
Pandas uses the unbiased estimator (N-1 in the denominator), whereas Numpy by default does not.
To make them behave the same, pass
ddof=1
tonumpy.std()
.
Different std in pandas vs numpy