 μ为所有样本数据的均值。 σ为所有样本数据的标准差
μ为所有样本数据的均值。 σ为所有样本数据的标准差 。
。
import numpy as np
#min-max 标准化
def normalize(x):
    x_max = np.max(x)
    x_min = np.min(x)
    return (x - x_min) / (x_max  - x_min)
#z-score 标准化
def standardize(x):
    ave = np.average(x)
    std = np.std(x)
    return (x - ave) / std
x = [14,6,7]
#y = normalize(x)
y = standardize(x)
print(y)

numpy.std() 求标准差的时候默认是除以 n 的,即是有偏的,np.std无偏样本标准差方式为加入参数 ddof = 1;
print(np.std([1,2,3])) print(np.std([1,2,3], ddof=1))

