[第15課] 統計:標準差
阿新 • • 發佈:2018-12-17
– Start
標準差 (standard deviation)
標準差σ是表述資料和均值之間的偏離程度的另一個重要標誌。它等於方差的平方根。
標準差公式: 樣本標準差公式:
Python
import numpy as np # 定義資料集 data_set = np.array([1, 2, 3, 8, 7]) print(f'data_set={data_set}') # 均值 mean = np.mean(data_set) print(f'mean of data_set = {mean}') # 方差 & 標準差 variance = np.var(data_set) standard_deviation = np.std(data_set) print(f'variance of data_set = {variance}') print(f'standard deviation of data_set = {standard_deviation}') # 樣本方差 & 樣本標準差 variance = np.var(data_set, ddof=1) sample_standard_deviation = np.std(data_set, ddof=1) print(f'variance of data_set = {variance}') print(f'sample standard deviation of data_set = {sample_standard_deviation}')
– 更多參見: – 聲 明:轉載請註明出處 – Last Updated on 2018-10-27 – Written by ShangBo on 2018-10-27 – End