Σ
SDCalc
ระดับกลางแนวคิด·12 min

สถิติทนทาน: MAD, IQR และวิธีที่ต้านทานค่าผิดปกติ

คู่มือฉบับสมบูรณ์สำหรับสถิติทนทาน รวมถึงค่าเบี่ยงเบนสัมบูรณ์จากมัธยฐาน (MAD) และพิสัยระหว่างควอร์ไทล์ (IQR) เรียนรู้ว่าเมื่อไหร่ควรใช้ตัววัดที่ต้านทานค่าผิดปกติ พร้อมตัวอย่างและโค้ด Python

ทำไมต้องสถิติทนทาน?

ส่วนเบี่ยงเบนมาตรฐานเป็นตัววัดการกระจายตัวที่ทรงพลัง แต่มีจุดอ่อนสำคัญ: ความไวต่อค่าผิดปกติอย่างมาก ค่าสุดโต่งเพียงค่าเดียวสามารถทำให้ SD เพิ่มขึ้นอย่างมาก ให้ภาพที่ทำให้เข้าใจผิดของความแปรผันโดยทั่วไป

สถิติทนทาน ให้ตัววัดการกระจายตัวที่ต้านทานอิทธิพลของค่าผิดปกติ ทำให้จำเป็นสำหรับข้อมูลในชีวิตจริงที่ข้อผิดพลาดในการวัด ข้อผิดพลาดในการป้อนข้อมูล หรือกรณีสุดโต่งจริงเป็นเรื่องปกติ

ตัวอย่าง: ผลกระทบของค่าผิดปกติ

ข้อมูล: 10, 12, 11, 13, 12, 11, 100 (ค่าผิดปกติหนึ่งค่า) ส่วนเบี่ยงเบนมาตรฐาน: 32.4 (ถูกครอบงำโดยค่าผิดปกติ) MAD: 1.0 (ไม่สนใจค่าผิดปกติ) IQR: 1.5 (ไม่สนใจค่าผิดปกติ)

จุดพังทลาย

“จุดพังทลาย” ของสถิติคือสัดส่วนของข้อมูลที่สามารถเป็นค่าสุดโต่งก่อนที่สถิตินั้นจะไร้ความหมาย SD มีจุดพังทลาย 0% (ค่าผิดปกติหนึ่งค่าสามารถทำลายมันได้) MAD และ IQR มีจุดพังทลาย 50% ข้อมูลครึ่งหนึ่งสามารถเป็นค่าผิดปกติและพวกมันยังคงทำงานได้

ค่าเบี่ยงเบนสัมบูรณ์จากมัธยฐาน (MAD)

MAD เป็นตัววัดการกระจายตัวที่ทนทานที่สุด คำนวณมัธยฐานของค่าเบี่ยงเบนสัมบูรณ์จากมัธยฐาน:

สูตร MAD

MAD = median(|xᵢ - median(x)|)
1

หามัธยฐาน

คำนวณมัธยฐานของชุดข้อมูล
2

คำนวณค่าเบี่ยงเบน

ลบมัธยฐานออกจากแต่ละค่าและหาค่าสัมบูรณ์
3

หา MAD

คำนวณมัธยฐานของค่าเบี่ยงเบนสัมบูรณ์เหล่านี้

การปรับ MAD เพื่อประมาณ σ: สำหรับข้อมูลที่มีการแจกแจงปกติ MAD ≈ 0.6745 × σ เพื่อประมาณ SD จาก MAD ให้คูณด้วย 1.4826:

ค่าประมาณ SD จาก MAD

σ̂ = 1.4826 × MAD

ทำไมต้อง 1.4826?

ตัวคูณนี้มาจากความสัมพันธ์ระหว่าง MAD และ SD สำหรับการแจกแจงปกติ มันทำให้ MAD ที่ถูกปรับเป็นตัวประมาณค่าที่ไม่เอนเอียงของส่วนเบี่ยงเบนมาตรฐานที่แท้จริงเมื่อข้อมูลเป็นปกติ

พิสัยระหว่างควอร์ไทล์ (IQR)

IQR วัดการกระจายตัวของข้อมูล 50% ตรงกลาง ช่วงระหว่างเปอร์เซ็นไทล์ที่ 25 ถึงที่ 75:

สูตร IQR

IQR = Q3 - Q1 = เปอร์เซ็นไทล์ที่ 75 - เปอร์เซ็นไทล์ที่ 25

IQR ถูกใช้กันอย่างแพร่หลายเพราะเข้าใจง่าย แสดงเป็นภาพในกล่องพล็อตได้ง่าย และเป็นพื้นฐานของ “กฎ 1.5×IQR” ที่ใช้กันทั่วไปสำหรับการตรวจจับค่าผิดปกติ

การปรับ IQR เพื่อประมาณ σ: สำหรับข้อมูลปกติ IQR ≈ 1.35 × σ เพื่อประมาณ SD จาก IQR:

ค่าประมาณ SD จาก IQR

σ̂ = IQR / 1.35 ≈ 0.7413 × IQR

การเปรียบเทียบตัววัดทนทาน

ส่วนเบี่ยงเบนมาตรฐาน

ใช้จุดข้อมูลทุกจุด · มีประสิทธิภาพสูงสุดสำหรับข้อมูลปกติ · ไวต่อค่าผิดปกติมาก · จุดพังทลาย: 0%

MAD

ทนทานที่สุด · ใช้มัธยฐาน (ไม่ใช่ค่าเฉลี่ย) · ไม่ได้รับผลจากค่าผิดปกติ · จุดพังทลาย: 50%

IQR

เข้าใจง่าย · ใช้ในกล่องพล็อต · ละเลย 50% สุดโต่ง · จุดพังทลาย: 25%

เมื่อไหร่ควรใช้สถิติทนทาน

  • การวิเคราะห์เชิงสำรวจ: เมื่อคุณไม่รู้ว่ามีค่าผิดปกติหรือไม่ เริ่มด้วยตัววัดทนทาน
  • ปัญหาคุณภาพข้อมูล: เมื่อข้อมูลอาจมีข้อผิดพลาดหรือปัญหาการวัด
  • การแจกแจงหางหนัก: เมื่อคาดว่าจะมีค่าสุดโต่ง (ผลตอบแทนทางการเงิน การเรียกร้องประกัน)
  • ตัวอย่างเล็ก: เมื่อค่าผิดปกติมีผลกระทบมากเกินสัดส่วนเนื่องจากข้อสังเกตน้อย
  • การตรวจจับค่าผิดปกติ: การใช้ SD เพื่อตรวจจับค่าผิดปกติเป็นวงจรอุบาทว์ ใช้ IQR หรือ MAD แทน

ตัวอย่างการนำไปใช้

Python
import numpy as np
from scipy import stats

def mad(data):
    """Median Absolute Deviation"""
    median = np.median(data)
    return np.median(np.abs(data - median))

def scaled_mad(data):
    """MAD scaled to estimate SD (for normal data)"""
    return 1.4826 * mad(data)

def iqr(data):
    """Interquartile Range"""
    return np.percentile(data, 75) - np.percentile(data, 25)

# Compare on data with outlier
data = [10, 12, 11, 13, 12, 11, 100]
print(f"SD: {np.std(data, ddof=1):.2f}")
print(f"MAD: {mad(data):.2f}")
print(f"Scaled MAD: {scaled_mad(data):.2f}")
print(f"IQR: {iqr(data):.2f}")

Further Reading

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.