Σ
SDCalc
入門Fundamentals·9 min

標準差是什麼?統計學基礎入門,完整解析定義、母體與樣本計算公式及Python實作範例,帶你搞懂數據離散程度

標準差是衡量數據離散程度的核心統計指標。本文將完整解析標準差定義,帶你一步步推導母體與樣本標準差的計算公式,並透過實際範例與Python程式碼詳細示範計算過程。同時深入探討68-95-99.7經驗法則、標準差與變異數的差異,以及分析時常見的統計陷阱,幫助你精準解讀數據背後的意義,立即掌握必備的數據分析基礎!

By Standard Deviation Calculator Team · Data Science Team·Published

標準差是什麼?

標準差是一種統計測度,用來量化一組數據值的變異或離散程度。標準差較低,表示數據點通常接近該組數據的平均數(期望值);標準差較高,則表示數據點散佈在較廣的範圍內。母體標準差以希臘字母 σ (sigma) 表示,樣本標準差則以 s 表示,這是描述性統計學中最基本的概念之一。

核心定義

標準差衡量每個數據點與平均數之間的典型距離。它告訴你,數據平均而言偏離中心值多少。

母體與樣本標準差

在計算標準差之前,必須先確認你的數據代表的是整個母體還是母體的樣本。母體包含指定群體的所有成員,而樣本則是該群體中具有代表性的子集。計算樣本標準差時需要進行數學調整——使用 n - 1(自由度,或稱 df)代替 N——以確保計算結果是母體變異數的不偏估計式。

母體標準差

當你擁有整個群體的數據時使用。以 σ 表示。變異數公式中的分母為 N(母體總數)。

樣本標準差

當你只有群體的子集時使用。以 s 表示。變異數公式中的分母為 n - 1(樣本數減一),用以修正偏差。

標準差公式解析

標準差的公式是先計算變異數,然後再開平方根。開平方根這個步驟至關重要,因為它能將離散程度的測度轉換回數據的原始單位。公式中的關鍵組成部分包含 xᵢ(每個數據值)、μ(母體或樣本平均數),以及 Nn(數據的總個數)。

母體標準差

σ = √[ Σ(xᵢ - μ)² / N ]

樣本標準差

s = √[ Σ(xᵢ - x̄)² / (n - 1) ]

逐步計算範例

假設我們有一組小考成績的數據:[4, 8, 6, 5, 3, 2, 8, 9, 2, 5],讓我們來計算它的樣本標準差。按照公式逐步計算,可以清楚看出變異數在最終開平方根之前是如何累積的。

1

計算平均數 (x̄)

將所有數值相加並除以數量:(4+8+6+5+3+2+8+9+2+5) / 10 = 52 / 10 = 5.2
2

減去平均數並平方

計算每個數值與平均數之差的平方:(4-5.2)² = 1.44, (8-5.2)² = 7.84, (6-5.2)² = 0.64,依此類推。
3

加總平方差

將所有平方後的結果相加:1.44 + 7.84 + 0.64 + 0.04 + 4.84 + 10.24 + 7.84 + 14.44 + 10.24 + 0.04 = 57.6
4

除以 n - 1(自由度)

將總和除以樣本數減一:57.6 / (10 - 1) = 57.6 / 9 = 6.4。這就是樣本變異數 (σ²)。
5

開平方根

對變異數開平方根:√6.4 ≈ 2.53。因此樣本標準差為 2.53。

使用 Python 計算標準差

手動計算標準差不僅容易出錯,尤其在處理大型數據集時更是如此。實務上,統計學家與資料科學家會使用 Python 等程式語言,透過內建函式庫來瞬間完成計算。

python
import statistics

data = [4, 8, 6, 5, 3, 2, 8, 9, 2, 5]

# 計算樣本標準差(預設)
sample_sd = statistics.stdev(data)
print(f"Sample SD: {sample_sd:.2f}")

# 計算母體標準差
pop_sd = statistics.pstdev(data)
print(f"Population SD: {pop_sd:.2f}")

經驗法則與標準差

當數據呈常態分配(鐘型曲線)時,標準差就變得極具預測性。經驗法則(又稱 68-95-99.7 法則)指出,幾乎所有的數據都會落在平均數的三個標準差範圍內。這讓分析師能夠快速找出離群值,並理解特定觀測值發生的機率。

與平均數的區間數據百分比應用場景
±1σ68.27%辨識常見的日常數值
±2σ95.45%設定信賴區間
±3σ99.73%偵測極端離群值

標準差與變異數的比較

變異數與標準差是密切相關的離散程度測度。變異數(σ² 或 s²)是各數據點與平均數之間差異平方的平均值,而標準差則是變異數的平方根。由於變異數的單位是原始單位的平方(例如:新台幣的平方、平方公分),在原始數據的情境下往往難以直觀解讀。標準差則透過將測度轉換回原始單位,解決了這個問題。

數據報告建議

在描述數據時,請務必將標準差與平均數一起呈現。因為標準差與平均數的單位相同(例如:新台幣、公分、公斤),它能提供一個直觀的離散程度測度,讓你的讀者能立刻理解數據的分散狀況。

常見的統計陷阱

雖然標準差是非常實用的工具,但卻經常遭到誤用。公式用錯或誤解數值的涵義,都可能導致數據分析出現瑕疵,進而得出錯誤的結論。

  • 將母體公式誤用於樣本:計算樣本時忘記使用 n - 1,會人為壓低算出的離散程度,進而低估了真實的母體變異數。
  • 將標準差套用於非常態分配:經驗法則僅適用於常態分配。對於高度偏態的數據,標準差可能無法準確反映其離散程度。
  • 將標準差與標準誤混淆:標準誤衡量的是樣本平均數估計的精確度,而標準差衡量的則是原始數據本身的離散程度。

當心離群值

標準差對極端離群值非常敏感。由於公式會將與平均數的差異平方,單一巨大的離群值就可能不成比例地膨脹標準差,讓數據看起來比實際情況更具變異性。

Further Reading

Sources

References and further authoritative reading used in preparing this article.

  1. 維基百科:標準差
  2. NIST/SEMATECH 統計方法電子手冊
  3. 可汗學院:統計與機率

How to Read This Article

A statistics tutorial is a practical interpretation guide, not just a formula dump. It refers to the assumptions, notation, and reporting language that analysts need when they explain a result to a teacher, manager, client, or reviewer. The article body covers the specific topic, while the sections below create a common interpretation frame that readers can reuse across related metrics.

Reading goalWhat to focus onCommon mistake
DefinitionWhat the metric is and what quantity it summarizesTreating the formula as self-explanatory
Formula choiceSample versus population assumptions and notationUsing n when n-1 is required or vice versa
InterpretationWhether the result indicates concentration, spread, or riskCalling a large value good or bad without context

Frequently Asked Questions

How should I interpret a high standard deviation?

A high standard deviation means the observations are spread farther from the mean on average. Whether that spread is acceptable depends on the context: wide dispersion might signal risk in finance, instability in manufacturing, or genuine natural variation in scientific data.

Why do some articles mention n while others mention n-1?

The denominator reflects the difference between population and sample formulas. Population variance and population standard deviation use N because the full dataset is known. Sample variance and sample standard deviation often use n-1 because Bessel’s correction reduces bias when estimating population spread from a sample.

What is a statistical interpretation guide?

A statistical interpretation guide is a page that moves beyond arithmetic and explains meaning. It tells you what a metric is, when the formula applies, and how to describe the result in plain English without overstating certainty.

Can I cite this article in a report?

You should cite the underlying authoritative reference for formal work whenever possible. This page is best used as an explanatory bridge that helps you understand the concept before quoting the original standard or handbook.

Why include direct citations on every article page?

Direct citations give readers a route to verify the definition, notation, and assumptions. That improves trust and reduces the chance that a simplified explanation is mistaken for the entire technical standard.

Authoritative References

These sources define the concepts referenced most often across our articles. Bessel's correction is a sample adjustment, variance is a squared measure of spread, and standard deviation is the square root of variance expressed in the same units as the data.