Foundations of Data Science 📂 Inferential Statistics · 8 of 8 137 min read

Type I & Type II Errors Explained

A richly illustrated, story-driven tutorial on Type I and Type II errors in hypothesis testing — covering the four-outcome decision matrix, three bell-curve diagrams, four real-world stories (courtroom, cancer screening, spam filter, insulin QC), a power calculation walkthrough, the replication crisis and its causes, a domain-by-domain error-priority guide, and a full quick-reference summary table.

🌐
SectionSection第 01 节

Two Ways to Be Wrong ⚖️ग़लत होने के दो तरीके ⚖️犯错的两种方式 ⚖️

Every decision made under uncertainty can be wrong. A doctor reading a scan, a judge weighing evidence, an engineer approving a bridge — each acts on incomplete information. In statistics there are exactly two ways a hypothesis test can fail you, and knowing both is the difference between careful science and dangerous science.

अनिश्चितता में लिया गया हर फ़ैसला ग़लत हो सकता है। Scan पढ़ता doctor, सबूत तौलता judge, पुल मंज़ूर करता engineer — सब अधूरी जानकारी पर काम करते हैं। Statistics में hypothesis test के ग़लत होने के ठीक दो तरीके हैं, और दोनों को जानना सावधान विज्ञान और ख़तरनाक विज्ञान के बीच का अंतर है।

在不确定中做出的每个决定都可能出错。读片的医生、权衡证据的法官、批准桥梁的工程师 —— 都基于不完整的信息行事。在统计学中,假设检验恰好有两种出错方式,了解这两种方式,就是严谨科学与危险科学的区别。

Think of a smoke detector. It can beep when there is no fire (a false alarm at 3 a.m. for burnt toast), or stay silent during a real fire (a disaster). With a given detector, making it less touchy means more silent fires; making it more touchy means more false alarms. Only a better detector — in statistics, more or better data — reduces both. Statisticians call these the Type I error and the Type II error.

Smoke detector सोचें। यह आग न होने पर भी बज सकता है (जली toast पर रात 3 बजे झूठा alarm), या असली आग में चुप रह सकता है (आपदा)। किसी दिए गए detector को कम संवेदनशील बनाने से ज़्यादा चुप आग; ज़्यादा संवेदनशील बनाने से ज़्यादा झूठे alarms. सिर्फ़ बेहतर detector — statistics में ज़्यादा या बेहतर data — दोनों घटाता है। Statisticians इन्हें Type I error और Type II error कहते हैं।

想想烟雾报警器。它可能没有火也响(凌晨 3 点因为烤焦的面包误报),也可能真着火时不响(酿成灾难)。对同一个报警器,调得不那么敏感,漏报的火灾就多;调得更敏感,误报就多。只有更好的报警器 —— 在统计中就是更多或更好的数据 —— 才能同时减少两者。统计学家称之为第一类错误和第二类错误。

💡
The Core Tensionमुख्य खिंचाव核心矛盾

For a given test and sample size, Type I and Type II errors pull against each other: lowering one raises the other. The way out is better evidence — a larger sample or more precise measurements — which can lower both. Every study design is a negotiation between these two risks.

किसी दिए गए test और sample size में Type I और Type II errors एक-दूसरे के ख़िलाफ़ खिंचते हैं: एक घटाने से दूसरा बढ़ता है। रास्ता है बेहतर सबूत — बड़ा sample या ज़्यादा सटीक माप — जो दोनों घटा सकता है। हर study design इन दो जोखिमों के बीच एक मोलभाव है।

对于给定的检验和样本量,第一类和第二类错误相互牵制:降低一个,另一个就升高。出路是更好的证据 —— 更大的样本或更精确的测量 —— 才能同时降低两者。每个研究设计都是这两种风险之间的权衡。


SectionSection第 02 节

Definitions — Crystal Clearपरिभाषाएँ — एकदम साफ़定义 — 一清二楚

Type I errorType I error第一类错误
α
  • Also called a false positiveदूसरा नाम: false positive又称假阳性
  • Rejecting H₀ when H₀ is TRUEH₀ सच होने पर उसे reject करनाH₀ 为真时拒绝了它
  • "Seeing" an effect that is not thereजो effect नहीं, उसे "देखना"“看见”了不存在的效应
  • P(reject H₀ | H₀ true) = αP(H₀ reject | H₀ सच) = αP(拒绝 H₀ | H₀ 为真) = α
  • You set it directlyआप सीधे तय करते हैं由你直接设定
  • Courtroom: convicting the innocentअदालत: बेगुनाह को सज़ा法庭:给无辜者定罪
Type II errorType II error第二类错误
β
  • Also called a false negativeदूसरा नाम: false negative又称假阴性
  • Keeping H₀ when H₀ is FALSEH₀ ग़लत होने पर उसे रखनाH₀ 为假时保留了它
  • Missing an effect that is realअसली effect को चूकना漏掉了真实存在的效应
  • P(keep H₀ | effect of a given size) = βP(H₀ रखें | दिए गए आकार का effect) = βP(保留 H₀ | 某个大小的效应) = β
  • Controlled through n, α and effect sizen, α और effect size से नियंत्रित通过 n、α 和效应量控制
  • Courtroom: freeing the guiltyअदालत: दोषी को छोड़ना法庭:放走罪犯
Statistical powerStatistical power检验力
1 − β
  • The chance of detecting a real effectअसली effect पकड़ने का chance发现真实效应的概率
  • Common target: 80% (β = 0.20)आम लक्ष्य: 80% (β = 0.20)常见目标:80%(β = 0.20)
  • Rises with sample sizeSample size के साथ बढ़ता है随样本量增大
  • Rises with effect sizeEffect size के साथ बढ़ता है随效应量增大
  • Rises with α (at a cost)α के साथ बढ़ता है (क़ीमत पर)随 α 增大(有代价)
📐
Two Small but Important Detailsदो छोटी पर ज़रूरी बातें两个小而重要的细节

α is conditional: it is the error rate when H₀ is true, not the chance that a significant result is wrong. β is not a single number: it depends on how big the real effect is. A study can have 90% power for a big effect and 20% power for a small one. That is why power is always stated for a specific effect size.

α शर्तिया है: यह H₀ सच होने पर error दर है, यह नहीं कि significant नतीजे के ग़लत होने का chance क्या है। β एक अकेली संख्या नहीं: यह असली effect के आकार पर निर्भर है। एक study की बड़े effect के लिए 90% power और छोटे के लिए 20% power हो सकती है। इसीलिए power हमेशा किसी ख़ास effect size के लिए बताई जाती है।

α 是条件概率:它是 H₀ 为真时的错误率,而不是“显著结果出错”的概率。β 不是单一数字:它取决于真实效应有多大。同一项研究对大效应可能有 90% 的检验力,对小效应只有 20%。所以检验力总要针对特定的效应量来说明。


SectionSection第 03 节

The Four-Outcome Matrixचार नतीजों का Matrix四种结果矩阵

Reality is one way or the other, and your decision is one way or the other. That gives four boxes — two correct, two errors. This 2×2 table is worth memorising.

सच्चाई एक या दूसरी तरह है, और आपका फ़ैसला एक या दूसरी तरह। इससे चार खाने बनते हैं — दो सही, दो ग़लतियाँ। यह 2×2 table याद रखने लायक़ है।

现实是这样或那样,你的决定也是这样或那样。于是有四个格子 —— 两个正确,两个错误。这张 2×2 表值得记住。

Your decisionआपका फ़ैसला你的决定H₀ actually TRUE (no real effect)H₀ असल में सच (कोई असली effect नहीं)H₀ 实际为真(没有真实效应)H₀ actually FALSE (real effect)H₀ असल में ग़लत (असली effect)H₀ 实际为假(存在真实效应)
Reject H₀ — "effect found"H₀ reject — "effect मिला"拒绝 H₀ ——“发现效应”❌ Type I error — false positive, probability αType I error — false positive, probability α第一类错误 —— 假阳性,概率 α✅ Correct — true positive, probability 1 − β (power)सही — true positive, probability 1 − β (power)正确 —— 真阳性,概率 1 − β(检验力)
Keep H₀ — "no effect found"H₀ रखें — "कोई effect नहीं मिला"保留 H₀ ——“未发现效应”✅ Correct — true negative, probability 1 − αसही — true negative, probability 1 − α正确 —— 真阴性,概率 1 − α❌ Type II error — false negative, probability βType II error — false negative, probability β第二类错误 —— 假阴性,概率 β
🐺
Memory Trick — The Boy Who Cried Wolfयाद रखने की तरकीब — भेड़िया आया!记忆窍门 —— 狼来了

Type I: the boy cries "wolf!" when there is no wolf — a false alarm. The villagers reject "no wolf" (H₀) although it is true. Type II: later a wolf really comes, but the villagers ignore him — a missed detection. They keep "no wolf" although it is false. Fun twist: the first errors made the second one more likely.

Type I: लड़का भेड़िया न होने पर भी "भेड़िया!" चिल्लाता है — झूठा alarm. गाँव वाले "कोई भेड़िया नहीं" (H₀) को reject करते हैं, जबकि वह सच है। Type II: बाद में सच में भेड़िया आता है, पर गाँव वाले उसे अनसुना कर देते हैं — छूटी पहचान। वे "कोई भेड़िया नहीं" रखते हैं, जबकि वह ग़लत है। मज़ेदार मोड़: पहली ग़लतियों ने दूसरी ग़लती को ज़्यादा संभव बना दिया।

第一类:没有狼时男孩喊“狼来了!”—— 误报。村民们拒绝了“没有狼”(H₀),尽管它是真的。第二类:后来狼真的来了,村民们却不理他 —— 漏报。他们保留了“没有狼”,尽管它是假的。有趣的是:前面的误报让后来的漏报更容易发生。


SectionSection第 04 节

Both Errors in Pictures — Understand Before the Maths 📊तस्वीरों में दोनों Errors — गणित से पहले समझें 📊图解两类错误 — 先理解,再算数 📊

Both errors come from the overlap of two curves: where the test statistic lands if H₀ is true (blue), and where it lands if the effect is real (purple). The decision line splits the axis into "keep H₀" and "reject H₀". Because the curves overlap, some blue area lies past the line (α) and some purple area lies before it (β).

दोनों errors दो curves के overlap से आती हैं: H₀ सच होने पर test statistic कहाँ गिरता है (नीला), और effect असली होने पर कहाँ (बैंगनी)। फ़ैसले की रेखा axis को "H₀ रखें" और "H₀ reject" में बाँटती है। Curves overlap करते हैं, इसलिए कुछ नीला area रेखा के पार है (α) और कुछ बैंगनी area रेखा से पहले (β)।

两类错误都来自两条曲线的重叠:H₀ 为真时检验统计量落在哪里(蓝),以及效应真实时落在哪里(紫)。判决线把坐标轴分成“保留 H₀”和“拒绝 H₀”两部分。由于曲线重叠,部分蓝色面积在线外(α),部分紫色面积在线内(β)。

📊 PICTURE 1 — α, β AND POWER ARE AREASतस्वीर 1 — α, β और POWER, AREAS हैं图 1 — α、β 和检验力都是面积
Type I, Type II and power Type I error (α) = 5.0%Type I error (α) = 5.0%第一类错误(α) = 5.0% H₀ H₁ z* = 1.645 H₀ true, but z lands past the lineH₀ सच, पर z रेखा के पारH₀ 为真,但 z 落在线外 Type II error (β) = 19.6%Type II error (β) = 19.6%第二类错误(β) = 19.6% H₀ H₁ z* = 1.645 effect real, but z stays before the lineeffect असली, पर z रेखा से पहले效应真实,但 z 停在线内 Power (1 − β) = 80.4%Power (1 − β) = 80.4%检验力(1 − β) = 80.4% H₀ H₁ z* = 1.645 effect real, and z lands past the lineeffect असली, और z रेखा के पार效应真实,且 z 落在线外

Example: right-tailed test, α = 0.05, and a real effect 2.5 standard errors away from H₀.

उदाहरण: right-tailed test, α = 0.05, और H₀ से 2.5 standard errors दूर असली effect.

示例:右侧检验,α = 0.05,真实效应距 H₀ 2.5 个标准误。

LIVELIVE互动Move the Decision Line — Live 2×2 Matrixफ़ैसले की रेखा खिसकाएँ — Live 2×2 Matrix移动判决线 — 实时 2×2 矩阵

Drag the decision line, or press play. Watch α (red), β (orange) and power (green) trade places in the curves and in the matrix. Then raise n or the effect: the purple curve moves away and β falls without changing α.

फ़ैसले की रेखा खिसकाएँ, या play दबाएँ। Curves और matrix में α (लाल), β (नारंगी) और power (हरा) की अदला-बदली देखें। फिर n या effect बढ़ाएँ: बैंगनी curve दूर जाता है और α बदले बिना β घटता है।

拖动判决线或点播放。看曲线和矩阵中 α(红)、β(橙)和检验力(绿)此消彼长。再增大 n 或效应:紫色曲线远离,β 下降而 α 不变。

💡
Why the Overlap Creates Both ErrorsOverlap दोनों Errors क्यों बनाता है为什么重叠会产生两类错误

The further apart the curves (a bigger effect), the less they overlap and the easier they are to tell apart. Moving the line left lowers β but raises α; moving it right does the opposite. To lower both, you must make both curves narrower — which means a bigger sample or less noisy measurements.

Curves जितने दूर (बड़ा effect), उतना कम overlap और उन्हें अलग करना उतना आसान। रेखा बाईं ओर ले जाने से β घटता है पर α बढ़ता है; दाईं ओर उल्टा। दोनों घटाने के लिए दोनों curves को पतला करना होगा — यानी बड़ा sample या कम शोर वाला माप।

两条曲线离得越远(效应越大),重叠越少,越容易区分。判决线左移,β 降低但 α 升高;右移则相反。要同时降低两者,必须让两条曲线都变窄 —— 也就是更大的样本或更少噪声的测量。


SectionSection第 05 节

Story 1 — The Courtroom 🏛️कहानी 1 — अदालत 🏛️故事 1 — 法庭 🏛️

Criminal justice starts from "innocent until proven guilty". The null hypothesis is innocence, and the prosecution must bring strong evidence to overturn it.

आपराधिक न्याय "दोष साबित होने तक बेगुनाह" से शुरू होता है। Null hypothesis बेगुनाही है, और prosecution को उसे पलटने के लिए मज़बूत सबूत लाना होता है।

刑事司法从“未经证明有罪即推定无罪”出发。原假设是无罪,控方必须拿出有力证据才能推翻。

⚖️ Justice System — Both Errors Mappedन्याय व्यवस्था — दोनों Errors司法系统 —— 两类错误对照
H₀
The defendant is innocent
आरोपी बेगुनाह है
被告无罪
H₁
The defendant is guilty
आरोपी दोषी है
被告有罪
Type IType I第一类
Convicting an innocent person. The court rejects innocence although it is true — a wrongful conviction. Cases overturned by later DNA evidence are real examples.
बेगुनाह को सज़ा। अदालत बेगुनाही को reject करती है, जबकि वह सच है — ग़लत सज़ा। बाद में DNA सबूत से पलटे गए मामले असली उदाहरण हैं।
给无辜者定罪。法庭拒绝了本为真实的无罪 —— 错判。后来被 DNA 证据推翻的案件就是真实的例子。
Type IIType II第二类
Acquitting a guilty person. The court keeps "innocent" although it is false — a guilty person walks free.
दोषी को बरी करना। अदालत "बेगुनाह" रखती है, जबकि वह ग़लत है — दोषी छूट जाता है।
放走罪犯。法庭保留了本为错误的“无罪” —— 罪犯逍遥法外。
Society's αसमाज का α社会的 α
"Beyond reasonable doubt" is a very small α, because convicting the innocent is judged worse than freeing the guilty. As the jurist William Blackstone put it: better that ten guilty persons escape than that one innocent suffers.
"संदेह से परे" एक बहुत छोटा α है, क्योंकि बेगुनाह को सज़ा, दोषी को छोड़ने से बुरी मानी जाती है। विधिवेत्ता William Blackstone के शब्दों में: दस दोषी छूट जाएँ, पर एक बेगुनाह को सज़ा न हो।
“排除合理怀疑”就是一个很小的 α,因为错判无辜被认为比放走罪犯更糟。正如法学家布莱克斯通所言:宁可放走十个有罪者,也不让一个无辜者受罚。
Trade-offसौदा权衡
A lower bar convicts more guilty people — and more innocent ones. A higher bar protects the innocent — and frees more guilty. No threshold removes both errors. Better evidence (forensics, more witnesses) is like a bigger sample: it reduces both.
नीची सीमा ज़्यादा दोषियों को सज़ा देती है — और ज़्यादा बेगुनाहों को भी। ऊँची सीमा बेगुनाहों को बचाती है — और ज़्यादा दोषियों को छोड़ती है। कोई सीमा दोनों errors नहीं हटाती। बेहतर सबूत (forensics, ज़्यादा गवाह) बड़े sample जैसा है: दोनों घटाता है।
门槛降低会让更多罪犯被定罪 —— 也让更多无辜者被定罪。门槛提高能保护无辜者 —— 也放走更多罪犯。没有哪个门槛能消除两类错误。更好的证据(法医鉴定、更多证人)就像更大的样本:能同时减少两者。

SectionSection第 06 节

Story 2 — The Cancer Screening Test 🏥कहानी 2 — Cancer Screening Test 🏥故事 2 — 癌症筛查 🏥

A hospital tries a new blood test for an early cancer. H₀: the patient does not have cancer. If a biomarker is above a threshold, the patient is sent for further tests such as a biopsy.

एक अस्पताल शुरुआती cancer के लिए नया blood test आज़माता है। H₀: मरीज़ को cancer नहीं है। अगर biomarker एक threshold से ऊपर हो, तो मरीज़ को biopsy जैसी आगे की जाँच के लिए भेजा जाता है।

一家医院试用一种早期癌症的新血液检测。H₀:患者没有癌症。若生物标志物高于阈值,患者会被安排做活检等进一步检查。

🩺 Cancer Screening — What Each Error CostsCancer Screening — हर Error की क़ीमत癌症筛查 —— 每种错误的代价
H₀ / H₁
H₀: no cancer | H₁: cancer
H₀: cancer नहीं | H₁: cancer
H₀:无癌症 | H₁:有癌症
Type IType I第一类
False positive — a healthy person is told they may have cancer. Worry, an unnecessary biopsy and its small risks, and cost. Its rate is 1 − specificity.
False positive — स्वस्थ व्यक्ति को बताया जाता है कि उसे cancer हो सकता है। चिंता, बेवजह biopsy और उसके छोटे जोखिम, और ख़र्च। इसकी दर 1 − specificity है।
假阳性 —— 健康人被告知可能患癌。焦虑、不必要的活检及其小风险,还有费用。其比率为 1 − 特异度。
Type IIType II第二类
False negative — a person with cancer is told they are fine. The cancer may grow past the early, treatable stage. Its rate is 1 − sensitivity.
False negative — cancer वाले व्यक्ति को बताया जाता है कि सब ठीक है। Cancer शुरुआती, इलाज-योग्य चरण से आगे बढ़ सकता है। इसकी दर 1 − sensitivity है।
假阴性 —— 患癌者被告知一切正常。癌症可能发展到超出早期可治疗阶段。其比率为 1 − 灵敏度。
Design choiceDesign का चुनाव设计选择
Because a miss is so serious, screening tests usually set a lower threshold — more alarms, fewer misses — and then confirm positives with a second, more accurate test.
क्योंकि चूक बहुत गंभीर है, screening tests आम तौर पर नीचा threshold रखते हैं — ज़्यादा alarms, कम चूक — और फिर positives की पुष्टि दूसरे, ज़्यादा सटीक test से करते हैं।
由于漏诊非常严重,筛查通常把阈值设得更低 —— 报警更多、漏诊更少 —— 然后用第二种更准确的检查确认阳性结果。
⚠️
Sensitivity and Specificity — the Clinical NamesSensitivity और Specificity — Clinical नाम灵敏度与特异度 —— 临床术语

Sensitivity = P(positive | disease) — the test's "power". Specificity = P(negative | no disease) — like 1 − α. For a given test, moving the threshold raises one and lowers the other. A better test (a more informative biomarker) can raise both.

Sensitivity = P(positive | बीमारी) — test की "power"। Specificity = P(negative | बीमारी नहीं) — 1 − α जैसा। किसी दिए गए test में threshold खिसकाने से एक बढ़ता है और दूसरा घटता है। एक बेहतर test (ज़्यादा जानकारी देने वाला biomarker) दोनों बढ़ा सकता है।

灵敏度 = P(阳性 | 患病) —— 检测的“检验力”。特异度 = P(阴性 | 未患病) —— 类似 1 − α。对同一检测,移动阈值会使一个升高、另一个降低。更好的检测(信息量更大的生物标志物)能同时提高两者。

🎯
The Base-Rate Trap — Why Most Positives Can Be FalseBase-Rate का जाल — ज़्यादातर Positives ग़लत क्यों हो सकते हैं基础比率陷阱 —— 为什么多数阳性可能是假的

Suppose 1% of people screened have the cancer, the test catches 90% of cancers (sensitivity) and gives a false alarm to 5% of healthy people (specificity 95%). Out of 100,000 people: 900 true positives, but 4,950 false positives. So only about 15% of positive results are real cancers. When the condition is rare, even a good test produces mostly false alarms — which is why positives are always confirmed.

मान लें जाँचे गए लोगों में 1% को cancer है, test 90% cancers पकड़ता है (sensitivity) और 5% स्वस्थ लोगों को झूठा alarm देता है (specificity 95%)। 1,00,000 लोगों में: 900 true positives, पर 4,950 false positives। यानी positive नतीजों में सिर्फ़ लगभग 15% असली cancer हैं। जब बीमारी दुर्लभ हो, तो अच्छा test भी ज़्यादातर झूठे alarms देता है — इसीलिए positives की हमेशा पुष्टि की जाती है।

假设受检人群中 1% 患癌,检测能查出 90% 的癌症(灵敏度),对 5% 的健康人误报(特异度 95%)。在 100,000 人中:900 个真阳性,但有 4,950 个假阳性。所以阳性结果中只有约 15% 是真正的癌症。疾病罕见时,即使好的检测也会产生大量误报 —— 这就是阳性结果总要复查的原因。

LIVELIVE互动Screen 1,000 People1,000 लोगों की Screening筛查 1,000 人

Set how common the disease is and where the biomarker threshold sits. Each square is one person. Watch how few of the positives are true cancers when the disease is rare — and how moving the threshold trades misses for false alarms.

बीमारी कितनी आम है और biomarker threshold कहाँ है, यह चुनें। हर खाना एक व्यक्ति है। देखें कि बीमारी दुर्लभ होने पर positives में कितने कम असली cancers हैं — और threshold खिसकाने से चूक और झूठे alarms की अदला-बदली कैसे होती है।

设置疾病的常见程度和生物标志物阈值。每个方块代表一个人。看看疾病罕见时,阳性中真正患癌的人有多少 —— 以及移动阈值如何在漏诊与误报之间取舍。


SectionSection第 07 节

Story 3 — The Email Spam Filter 📧कहानी 3 — Email Spam Filter 📧故事 3 — 垃圾邮件过滤器 📧

A spam filter makes a decision for every incoming email. H₀: this email is legitimate. H₁: it is spam. Deliver it or move it to the spam folder?

Spam filter हर आने वाले email पर फ़ैसला लेता है। H₀: यह email असली है। H₁: यह spam है। Inbox में भेजें या spam folder में?

垃圾邮件过滤器要为每封来信做决定。H₀:这封邮件是正常的。H₁:它是垃圾邮件。送进收件箱还是移到垃圾箱?

📬 Spam Filter — Error AnalysisSpam Filter — Error Analysis垃圾邮件过滤器 —— 错误分析
Type IType I第一类
A real email goes to spam. A job offer, a client's invoice or a message from your boss is missed. This can be costly.
असली email spam में चला जाता है। नौकरी का offer, client का invoice या boss का message छूट जाता है। यह महँगा हो सकता है।
正常邮件进了垃圾箱。工作邀约、客户发票或老板的消息被错过。代价可能很高。
Type IIType II第二类
Spam reaches the inbox. Annoying and time-wasting, and possibly dangerous if it is phishing — but usually you can spot and delete it.
Spam inbox में पहुँच जाता है। परेशान करने वाला और समय की बर्बादी, और phishing हो तो ख़तरनाक भी — पर आम तौर पर आप उसे पहचानकर delete कर सकते हैं।
垃圾邮件进了收件箱。烦人又浪费时间,若是钓鱼邮件还可能危险 —— 但通常你能认出并删掉。
Design priorityDesign प्राथमिकता设计侧重
Most providers keep the Type I rate very low — they would rather let some spam through than lose real mail. Security-focused companies may accept more Type I errors to block more phishing.
ज़्यादातर providers Type I दर बहुत कम रखते हैं — असली mail खोने से बेहतर है कुछ spam आने देना। Security पर ध्यान देने वाली कंपनियाँ ज़्यादा phishing रोकने के लिए ज़्यादा Type I errors स्वीकार कर सकती हैं।
多数服务商把第一类错误率压得很低 —— 宁可放过一些垃圾邮件,也不丢真邮件。注重安全的公司可能接受更多第一类错误,以拦截更多钓鱼邮件。
Your feedbackआपकी feedback你的反馈
Clicking "not spam" or "report spam" helps the filter learn: over time, it improves the filter itself, which can lower both errors.
"not spam" या "report spam" दबाने से filter सीखता है: समय के साथ filter ख़ुद बेहतर होता है, जो दोनों errors घटा सकता है।
点击“不是垃圾邮件”或“举报垃圾邮件”能帮助过滤器学习:随着时间推移,过滤器本身变得更好,可以同时降低两类错误。

SectionSection第 08 节

Story 4 — The Insulin Factory 🏭कहानी 4 — Insulin Factory 🏭故事 4 — 胰岛素工厂 🏭

A pharmaceutical factory makes insulin vials. Each batch is tested to check that its strength is on specification. H₀: the batch is in spec (μ = 100 IU/mL). A Type I error destroys a good batch. A Type II error ships an off-spec batch to patients with diabetes.

एक pharmaceutical factory insulin vials बनाती है। हर batch की जाँच होती है कि उसकी ताक़त specification पर है। H₀: batch spec में है (μ = 100 IU/mL)। Type I error अच्छे batch को नष्ट करता है। Type II error ग़लत batch को diabetes के मरीज़ों तक भेजता है।

一家制药厂生产胰岛素小瓶。每批都要检测浓度是否符合规格。H₀:该批符合规格(μ = 100 IU/mL)。第一类错误会销毁合格批次;第二类错误则把不合格批次发给糖尿病患者。

🧮 Insulin Batch QC — Two-Tailed t-testInsulin Batch QC — Two-Tailed t-test胰岛素批次质检 —— 双侧 t 检验
DataData数据
n = 20 vials, x̄ = 97.4 IU/mL, s = 4.2 IU/mL
n = 20 vials, x̄ = 97.4 IU/mL, s = 4.2 IU/mL
n = 20 瓶,x̄ = 97.4 IU/mL,s = 4.2 IU/mL
Step 1Step 1第 1 步
SE = 4.2 / √20 = 4.2 / 4.472 = 0.939
SE = 4.2 / √20 = 4.2 / 4.472 = 0.939
SE = 4.2 / √20 = 4.2 / 4.472 = 0.939
Step 2Step 2第 2 步
t = (97.4 − 100) / 0.939 = −2.77, df = 19, p = 0.012
t = (97.4 − 100) / 0.939 = −2.77, df = 19, p = 0.012
t = (97.4 − 100) / 0.939 = −2.77,df = 19,p = 0.012
α = 0.01
Critical t = ±2.861 → |−2.77| < 2.861 → fail to reject: the batch ships.
Critical t = ±2.861 → |−2.77| < 2.861 → reject नहीं: batch भेजा जाता है।
临界 t = ±2.861 → |−2.77| < 2.861 → 不拒绝:该批发货。
α = 0.05
Critical t = ±2.093 → 2.77 > 2.093 → reject H₀: the batch is held.
Critical t = ±2.093 → 2.77 > 2.093 → H₀ reject: batch रोका जाता है।
临界 t = ±2.093 → 2.77 > 2.093 → 拒绝 H₀:该批被扣留。
The catchपेच关键
A "strict" α = 0.01 sounds safe, but here it protects the factory's good batches, not the patients. The error that harms patients is Type II (shipping a bad batch), and a smaller α makes Type II errors more likely. For patient safety you want a larger α here — or, better, a design that puts the burden of proof on showing the batch is in spec.
"सख़्त" α = 0.01 सुरक्षित लगता है, पर यहाँ यह factory के अच्छे batches को बचाता है, मरीज़ों को नहीं। मरीज़ों को नुक़सान करने वाली error Type II है (ख़राब batch भेजना), और छोटा α Type II errors को ज़्यादा संभव बनाता है। मरीज़ों की सुरक्षा के लिए यहाँ बड़ा α चाहिए — या बेहतर, ऐसा design जिसमें batch के spec में होने को साबित करना पड़े।
“严格”的 α = 0.01 听起来很安全,但在这里它保护的是工厂的合格批次,而不是患者。伤害患者的是第二类错误(发出不合格批次),而更小的 α 会让第二类错误更可能发生。为了患者安全,这里应该用更大的 α —— 或者更好,采用必须证明该批确实合格的设计。
🔁
Flip the Burden of Proof: Equivalence Testingसबूत का बोझ पलटें: Equivalence Testing反转举证责任:等效性检验

In quality control, "we found no significant difference" is weak proof that a batch is good — a small or noisy sample also finds nothing. Equivalence testing (for example the TOST procedure) sets H₀: "the batch is outside the tolerance" and must reject it to release the batch. Now the error that harms patients is controlled at α.

Quality control में "कोई significant अंतर नहीं मिला" इस बात का कमज़ोर सबूत है कि batch अच्छा है — छोटा या शोर भरा sample भी कुछ नहीं पाता। Equivalence testing (जैसे TOST तरीका) H₀ रखता है: "batch tolerance से बाहर है", और batch छोड़ने के लिए उसे reject करना ज़रूरी है। अब मरीज़ों को नुक़सान करने वाली error α पर नियंत्रित होती है।

在质量控制中,“没有发现显著差异”并不能有力证明批次合格 —— 样本小或噪声大时同样什么也发现不了。等效性检验(例如 TOST 方法)设 H₀:“该批超出公差”,必须拒绝它才能放行。这样伤害患者的那种错误就被控制在 α。


SectionSection第 09 节

What Controls Each Errorहर Error को क्या नियंत्रित करता है什么控制着每种错误

Changeबदलाव变化Type I (α)Type I (α)第一类(α)Type II (β)Type II (β)第二类(β)PowerPower检验力
Raise α (0.01 → 0.05)α बढ़ाएँ (0.01 → 0.05)提高 α(0.01 → 0.05)Up ↑बढ़ता ↑升 ↑Down ↓घटता ↓降 ↓Up ↑बढ़ती ↑升 ↑
Lower α (0.05 → 0.01)α घटाएँ (0.05 → 0.01)降低 α(0.05 → 0.01)Down ↓घटता ↓降 ↓Up ↑बढ़ता ↑升 ↑Down ↓घटती ↓降 ↓
Bigger sample nबड़ा sample n更大样本 nNo changeकोई बदलाव नहीं不变Down ↓घटता ↓降 ↓Up ↑बढ़ती ↑升 ↑
Bigger true effect δबड़ा असली effect δ更大真实效应 δNo changeकोई बदलाव नहीं不变Down ↓घटता ↓降 ↓Up ↑बढ़ती ↑升 ↑
Less noise (smaller σ)कम शोर (छोटा σ)更少噪声(更小 σ)No changeकोई बदलाव नहीं不变Down ↓घटता ↓降 ↓Up ↑बढ़ती ↑升 ↑
One-tailed instead of two-tailedTwo-tailed की जगह one-tailed单侧代替双侧Same total αवही कुल α总 α 不变Down in the predicted directionअनुमानित दिशा में घटता预测方向上降低Up in the predicted directionअनुमानित दिशा में बढ़ती预测方向上升高
✅
The Only "Free Lunch": Better Evidenceइकलौता "Free Lunch": बेहतर सबूत唯一的“免费午餐”:更好的证据

Every other knob trades one error for the other. A bigger sample (or more precise measurement) lowers β without raising α. That is why power analysis — working out the n needed for, say, 80% power at your α — is the first step of a well-designed study.

बाक़ी हर knob एक error के बदले दूसरी देता है। बड़ा sample (या ज़्यादा सटीक माप) α बढ़ाए बिना β घटाता है। इसीलिए power analysis — अपने α पर, जैसे 80% power के लिए ज़रूरी n निकालना — अच्छी तरह design की गई study का पहला step है।

其他每个旋钮都是用一种错误换另一种。更大的样本(或更精确的测量)能在不提高 α 的情况下降低 β。这就是为什么功效分析 —— 计算在你的 α 下达到如 80% 检验力所需的 n —— 是设计良好研究的第一步。


SectionSection第 10 节

Which Error Matters More? — By Fieldकौन-सी Error ज़्यादा मायने रखती है? — क्षेत्र के अनुसार哪种错误更要紧?— 按领域

Fieldक्षेत्र领域Decisionफ़ैसला决定Usually worseआम तौर पर बदतर通常更糟How it is handledकैसे संभाला जाता है应对方式
⚖️ Criminal lawआपराधिक क़ानून刑法Convict / acquitसज़ा / बरी定罪 / 无罪Type I (convict the innocent)Type I (बेगुनाह को सज़ा)第一类(错判无辜)Very high evidence barबहुत ऊँची सबूत सीमा极高的证据门槛
🏥 Cancer screeningCancer screening癌症筛查Refer / clearआगे भेजें / साफ़转诊 / 排除Type II (miss a cancer)Type II (cancer छूटना)第二类(漏诊)Low threshold, then a confirmatory testनीचा threshold, फिर पुष्टि वाला test低阈值,再做确认检查
💊 Drug approvalदवा की मंज़ूरी药物审批Approve / rejectमंज़ूर / नामंज़ूर批准 / 拒绝Type I (approve a useless drug)Type I (बेअसर दवा मंज़ूर)第一类(批准无效药)Two-sided α = 0.05, often two trialsTwo-sided α = 0.05, अक्सर दो trials双侧 α = 0.05,常需两项试验
☢️ Safety monitoringSafety monitoring安全监测Alarm / stay quietAlarm / चुप报警 / 不报Type II (miss a hazard)Type II (ख़तरा छूटना)第二类(漏掉危险)Lenient α (e.g. 0.10), extra checksनरम α (जैसे 0.10), अतिरिक्त जाँच宽松 α(如 0.10),额外检查
📧 Spam filteringSpam filtering垃圾邮件过滤Block / deliverरोकें / भेजें拦截 / 投递Type I (block real mail)Type I (असली mail रोकना)第一类(拦截正常邮件)Very low false-positive rateबहुत कम false-positive दर极低的误报率
📈 A/B testingA/B testingA/B 测试Launch / keep oldLaunch / पुराना रखें上线 / 保留旧版Both matterदोनों मायने रखते हैं两者都要紧α = 0.05 with 80% power80% power के साथ α = 0.05α = 0.05,检验力 80%
🔬 Particle physicsParticle physics粒子物理Claim a new particleनए कण का दावा宣布新粒子Type I (false discovery)Type I (झूठी खोज)第一类(虚假发现)5σ (α ≈ 2.9 × 10⁻⁷)5σ (α ≈ 2.9 × 10⁻⁷)5σ(α ≈ 2.9 × 10⁻⁷)
🧬 Genomics (GWAS)Genomics (GWAS)基因组学(GWAS)Gene linked to disease?क्या gene बीमारी से जुड़ा है?基因与疾病相关吗?Type I (false link)Type I (झूठा संबंध)第一类(虚假关联)α = 5 × 10⁻⁸

SectionSection第 11 节

Worked Example — Power and Sample Size 🔢हल किया उदाहरण — Power और Sample Size 🔢例题 — 检验力与样本量 🔢

A researcher wants to know if a new teaching method raises exam scores by at least 5 points (the smallest gain that matters). Under the old method scores have μ = 70 and σ = 15. One class of students is taught the new way and compared with the known mean of 70. How many students are needed for 80% power at two-tailed α = 0.05?

एक researcher जानना चाहता है कि क्या नई teaching method exam scores कम से कम 5 points बढ़ाती है (सबसे छोटी बढ़त जो मायने रखती है)। पुरानी method में scores का μ = 70 और σ = 15 है। छात्रों की एक class को नए तरीके से पढ़ाया जाता है और ज्ञात mean 70 से तुलना की जाती है। Two-tailed α = 0.05 पर 80% power के लिए कितने छात्र चाहिए?

一位研究者想知道新教学法能否把考试成绩提高至少 5 分(有意义的最小提升)。旧方法下成绩 μ = 70,σ = 15。用新方法教一个班,再与已知均值 70 比较。在双侧 α = 0.05 下要达到 80% 检验力,需要多少学生?

Sample-size formula (one group vs a known mean)Sample-size formula (एक group vs ज्ञात mean)样本量公式(一组 vs 已知均值)
n = (z_α/2 + z_β)² × σ² / δ²
δ = smallest effect worth detecting, z_α/2 = 1.96 for two-tailed α = 0.05, z_β = 0.842 for 80% power.
δ = पकड़ने लायक़ सबसे छोटा effect, two-tailed α = 0.05 के लिए z_α/2 = 1.96, 80% power के लिए z_β = 0.842.
δ = 值得检测的最小效应,双侧 α = 0.05 时 z_α/2 = 1.96,80% 检验力时 z_β = 0.842。
Calculationगणना计算
n = (1.96 + 0.842)² × 225 / 25
(2.802)² = 7.85; 7.85 × 9 = 70.6 → 71 students.
(2.802)² = 7.85; 7.85 × 9 = 70.6 → 71 छात्र।
(2.802)² = 7.85;7.85 × 9 = 70.6 → 71 名学生。
Comparing two groups instead?दो groups की तुलना हो तो?如果比较两组呢?
n per group ≈ 2 × 70.6 ≈ 142
If a new-method class is compared with an old-method class (both measured), each group needs about twice as many: 142 per group.
अगर नई method वाली class की पुरानी method वाली class से तुलना हो (दोनों मापे गए), तो हर group को लगभग दोगुना चाहिए: हर group में 142।
如果把新方法班与旧方法班比较(两组都要测量),每组约需两倍人数:每组 142 人。
🧮 Power at Different Sample Sizes (one group)अलग-अलग Sample Sizes पर Power (एक group)不同样本量下的检验力(一组)
n = 20
Power ≈ 32%, β ≈ 0.68. Two out of three such studies would miss a real 5-point gain — badly underpowered.
Power ≈ 32%, β ≈ 0.68. ऐसी तीन में से दो studies असली 5-point बढ़त चूक जाएँगी — बहुत कम power.
检验力 ≈ 32%,β ≈ 0.68。三项这样的研究中有两项会错过真实的 5 分提升 —— 严重不足。
n = 45
Power ≈ 61%, β ≈ 0.39. Better, but still a 2-in-5 chance of missing the effect.
Power ≈ 61%, β ≈ 0.39. बेहतर, पर effect चूकने का अब भी 5 में 2 chance.
检验力 ≈ 61%,β ≈ 0.39。好一些,但仍有五分之二的概率漏掉效应。
n = 71
Power ≈ 80%, β ≈ 0.20. The usual target: one in five real effects will still be missed.
Power ≈ 80%, β ≈ 0.20. आम लक्ष्य: पाँच में से एक असली effect फिर भी छूटेगा।
检验力 ≈ 80%,β ≈ 0.20。常用目标:仍有五分之一的真实效应会被漏掉。
n = 117
Power ≈ 95%, β ≈ 0.05. For high-stakes questions — about 65% more students than the 80% design.
Power ≈ 95%, β ≈ 0.05. बड़े जोखिम वाले सवालों के लिए — 80% design से लगभग 65% ज़्यादा छात्र।
检验力 ≈ 95%,β ≈ 0.05。用于高风险问题 —— 比 80% 的设计多约 65% 的学生。
📈 PICTURE 2 — POWER RISES WITH SAMPLE SIZEतस्वीर 2 — SAMPLE SIZE के साथ POWER बढ़ती है图 2 — 检验力随样本量上升
Power versus sample size 0% 25% 50% 80% 95% 0 25 50 75 100 125 150 n=20: 32% n=45: 61% n=71: 80% n=117: 95% Power to detect a 5-point gain (σ = 15, two-tailed α = 0.05) against the number of students5-point बढ़त पकड़ने की power (σ = 15, two-tailed α = 0.05) बनाम छात्रों की संख्या检测 5 分提升的检验力(σ = 15,双侧 α = 0.05)随学生人数的变化

SectionSection第 12 节

The Replication Crisis — Type I Errors at Scale 📉Replication Crisis — बड़े पैमाने पर Type I Errors 📉可重复性危机 — 大规模的第一类错误 📉

Between 2011 and 2015 a large team (the Open Science Collaboration) repeated 100 published psychology studies. About 97% of the originals had reported significant results; only about 36% of the repeats did. Not every failed repeat means the original was a Type I error — repeats can miss real effects too — but the results showed that the false-positive rate in the published record was far above 5%.

2011 से 2015 के बीच एक बड़ी team (Open Science Collaboration) ने 100 प्रकाशित psychology studies दोहराईं। मूल studies में लगभग 97% ने significant नतीजे बताए थे; दोहराने पर सिर्फ़ लगभग 36% में मिले। हर असफल दोहराव का मतलब यह नहीं कि मूल study Type I error थी — दोहराव भी असली effects चूक सकते हैं — पर नतीजों ने दिखाया कि प्रकाशित साहित्य में false-positive दर 5% से बहुत ऊपर थी।

2011 至 2015 年间,一个大型团队(开放科学合作组织)重复了 100 项已发表的心理学研究。原始研究中约 97% 报告了显著结果;重复研究中只有约 36% 显著。并非每次重复失败都说明原研究是第一类错误 —— 重复研究也可能漏掉真实效应 —— 但结果表明,已发表文献中的假阳性率远高于 5%。

How can the real false-positive rate climb so far above α? The two simulations below show the two biggest reasons.

असली false-positive दर α से इतना ऊपर कैसे चढ़ सकती है? नीचे के दो simulations दो सबसे बड़े कारण दिखाते हैं।

真实的假阳性率怎么会远远超过 α?下面两个模拟展示了两大原因。

LIVELIVE互动A World of 100 Studies100 Studies की दुनिया100 项研究的世界

Each square is one study. Set how often the tested effect is real, and how much power each study has. Stars are "significant" results — the ones that get published. Red stars are Type I errors.

हर खाना एक study है। तय करें कि जाँचा गया effect कितनी बार असली है, और हर study की power कितनी है। सितारे "significant" नतीजे हैं — जो प्रकाशित होते हैं। लाल सितारे Type I errors हैं।

每个方块是一项研究。设置被检验的效应真实存在的比例,以及每项研究的检验力。星号是“显著”结果 —— 也就是会被发表的那些。红色星号是第一类错误。

🚨 Five Practices That Inflate False Positivesपाँच आदतें जो False Positives बढ़ाती हैं抬高假阳性的五种做法
1
HARKing — Hypothesising After the Results are Known. Run a study with no firm hypothesis, find any significant pattern, then write it up as if it was predicted. The "test" was chosen by the data, so the 5% guarantee no longer holds.
HARKing — नतीजे जानने के बाद hypothesis बनाना। बिना पक्की hypothesis के study चलाएँ, कोई भी significant pattern ढूँढें, फिर ऐसे लिखें जैसे पहले से अनुमान था। "Test" data ने चुना, इसलिए 5% की गारंटी अब लागू नहीं।
HARKing —— 知道结果后再提假设。没有明确假设就做研究,找到任何显著模式,再写成像是事先预测的。“检验”是由数据挑出来的,5% 的保证就不再成立。
2
Many tests, no correction. 20 tests at α = 0.05 give at least one false positive about 64% of the time. Reporting only the significant one hides this.
कई tests, कोई correction नहीं। α = 0.05 पर 20 tests लगभग 64% बार कम से कम एक false positive देते हैं। सिर्फ़ significant वाला बताने से यह छिप जाता है।
多重检验不校正。α = 0.05 做 20 个检验,约 64% 的情况下至少一个假阳性。只报告显著的那个就掩盖了这一点。
3
Optional stopping. Checking the data again and again and stopping as soon as p < 0.05 inflates false positives — with 10 peeks, to about 20% (see the simulation below).
Optional stopping. बार-बार data जाँचना और p < 0.05 होते ही रुक जाना false positives बढ़ाता है — 10 बार झाँकने पर लगभग 20% तक (नीचे simulation देखें)।
可选停止。反复查看数据、一到 p < 0.05 就停止,会抬高假阳性率 —— 偷看 10 次时约达 20%(见下方模拟)。
4
Publication bias. Journals prefer significant results; null results stay in file drawers. The published record then over-represents lucky false positives.
Publication bias. Journals significant नतीजे पसंद करते हैं; null नतीजे दराज़ों में पड़े रहते हैं। तब प्रकाशित साहित्य में किस्मत वाले false positives ज़्यादा दिखते हैं।
发表偏倚。期刊偏爱显著结果,阴性结果被锁进抽屉。于是已发表文献中走运的假阳性比例过高。
5
Underpowered studies. Low power means real effects are often missed (Type II). It also means that, among the significant results, a larger share are false positives (the simulation above shows this), and the real ones that pass tend to have exaggerated effect sizes — the "winner's curse".
कम power वाली studies. कम power मतलब असली effects अक्सर छूटते हैं (Type II)। इसका मतलब यह भी है कि significant नतीजों में false positives का हिस्सा बड़ा होता है (ऊपर का simulation यह दिखाता है), और जो असली पास होते हैं उनके effect sizes अक्सर बढ़े-चढ़े होते हैं — "winner's curse"।
检验力不足的研究。检验力低意味着真实效应常被漏掉(第二类)。这也意味着在显著结果中,假阳性的占比更高(上面的模拟显示了这一点),而那些通过的真实效应往往被夸大 ——“赢家的诅咒”。
LIVELIVE互动Optional Stopping — Peeking Until It WorksOptional Stopping — काम होने तक झाँकना可选停止 — 偷看到成功为止

H₀ is TRUE: there is no effect at all. The researcher checks the p-value after every 10 people and stops as soon as p < 0.05. Run one study to watch the path, then 1,000 to see the real false-positive rate. Change the number of peeks.

H₀ सच है: कोई effect नहीं। Researcher हर 10 लोगों के बाद p-value देखता है और p < 0.05 होते ही रुक जाता है। रास्ता देखने के लिए एक study चलाएँ, फिर असली false-positive दर देखने के लिए 1,000. झाँकने की संख्या बदलें।

H₀ 为真:完全没有效应。研究者每 10 人查看一次 p 值,一旦 p < 0.05 就停止。先运行一项研究看路径,再运行 1,000 项看真实的假阳性率。改变偷看次数试试。

⚠️
The Fix: Pre-Registration and Registered Reportsहल: Pre-Registration और Registered Reports对策:预注册与注册报告

Researchers now pre-register their hypotheses, sample size, α and analysis plan in a public registry (such as OSF or ClinicalTrials.gov) before collecting data. In a Registered Report, the journal even accepts the paper before the results are known. The effect is striking: a 2021 study found that about 96% of ordinary psychology papers supported their hypothesis, against about 44% of Registered Reports — a sign of how much flexibility and publication bias had inflated "success".

Researchers अब data जुटाने से पहले अपनी hypotheses, sample size, α और analysis योजना किसी सार्वजनिक registry (जैसे OSF या ClinicalTrials.gov) पर pre-register करते हैं। Registered Report में journal नतीजे आने से पहले ही paper स्वीकार कर लेता है। असर साफ़ है: 2021 की एक study में पाया गया कि लगभग 96% सामान्य psychology papers ने अपनी hypothesis का समर्थन किया, जबकि Registered Reports में लगभग 44% ने — यह दिखाता है कि लचीलेपन और publication bias ने "सफलता" को कितना बढ़ा दिया था।

研究者现在会在收集数据前,把假设、样本量、α 和分析计划预注册到公开平台(如 OSF 或 ClinicalTrials.gov)。在注册报告中,期刊甚至在结果出来之前就接收论文。效果很明显:2021 年的一项研究发现,约 96% 的普通心理学论文支持其假设,而注册报告中只有约 44% —— 可见分析的灵活性和发表偏倚把“成功率”抬高了多少。


SectionSection第 13 节

Python ImplementationPython ImplementationPython 实现

Power and sample size for the teaching exampleTeaching उदाहरण के लिए power और sample size教学例子的检验力与样本量

import numpy as np
from scipy import stats

# Teaching method: detect +5 points, σ = 15, two-tailed α = 0.05, one group vs known μ = 70
delta, sigma, alpha = 5, 15, 0.05
za, zb = stats.norm.ppf(1 - alpha/2), stats.norm.ppf(0.80)
n80 = (za + zb)**2 * sigma**2 / delta**2
print(f"n for 80% power: {n80:.1f} → {np.ceil(n80):.0f} students")
n95 = (za + stats.norm.ppf(0.95))**2 * sigma**2 / delta**2
print(f"n for 95% power: {n95:.1f} → {np.ceil(n95):.0f} students")

def power(n):
    shift = delta / (sigma / np.sqrt(n))
    return stats.norm.sf(za - shift) + stats.norm.cdf(-za - shift)

for n in [20, 45, 71, 117]:
    print(f"n = {n:3d}: power = {power(n)*100:4.1f}%   β = {(1-power(n))*100:4.1f}%")

# Comparing TWO groups (new method vs old) needs about twice as many per group
print(f"\nTwo-group design: about {np.ceil(2*n80):.0f} students in EACH group")
OUTPUT
n for 80% power: 70.6 → 71 students n for 95% power: 117.0 → 117 students n = 20: power = 32.0% β = 68.0% n = 45: power = 60.9% β = 39.1% n = 71: power = 80.2% β = 19.8% n = 117: power = 95.0% β = 5.0% Two-group design: about 142 students in EACH group

Insulin batch: same data, two α valuesInsulin batch: वही data, दो α胰岛素批次:同样数据,两个 α

from scipy import stats

# Insulin batch: H₀ μ = 100 IU/mL, two-tailed one-sample t-test
xbar, s, n, mu0 = 97.4, 4.2, 20, 100
t = (xbar - mu0) / (s / n ** 0.5)
p = 2 * stats.t.sf(abs(t), df=n - 1)
print(f"t = {t:.3f}, df = {n-1}, p = {p:.4f}")
for a in [0.01, 0.05]:
    crit = stats.t.ppf(1 - a/2, n - 1)
    print(f"α = {a}: critical ±{crit:.3f} → {'reject H₀ (destroy batch)' if p < a else 'fail to reject (ship batch)'}")
OUTPUT
t = -2.768, df = 19, p = 0.0122 α = 0.01: critical ±2.861 → fail to reject (ship batch) α = 0.05: critical ±2.093 → reject H₀ (destroy batch)

Simulating both error ratesदोनों error दरों का simulation模拟两种错误率

import numpy as np
from scipy import stats

rng = np.random.default_rng(7)
reps, n, alpha = 20_000, 25, 0.05

# World 1: H₀ true (no effect) → every rejection is a Type I error
x0 = rng.normal(0, 1, (reps, n))
p0 = stats.ttest_1samp(x0, 0, axis=1).pvalue
print(f"H₀ true : Type I error rate  = {np.mean(p0 < alpha)*100:5.2f}%  (α = 5%)")

# World 2: real effect d = 0.5 → every non-rejection is a Type II error
x1 = rng.normal(0.5, 1, (reps, n))
p1 = stats.ttest_1samp(x1, 0, axis=1).pvalue
beta = np.mean(p1 >= alpha)
print(f"d = 0.5 : Type II error rate = {beta*100:5.2f}%  → power = {(1-beta)*100:.1f}%")
OUTPUT
H₀ true : Type I error rate = 5.04% (α = 5%) d = 0.5 : Type II error rate = 33.27% → power = 66.7%

The base-rate trap in numbersसंख्याओं में base-rate का जाल用数字看基础比率陷阱

# Screening with a rare disease: what does a positive result mean?
prev, sens, spec = 0.01, 0.90, 0.95        # 1% have it; test catches 90%; 5% false alarms
N = 100_000
sick, healthy = N * prev, N * (1 - prev)
tp, fn = sick * sens, sick * (1 - sens)
fp, tn = healthy * (1 - spec), healthy * spec
print(f"True positives  {tp:7.0f}   False negatives {fn:7.0f}")
print(f"False positives {fp:7.0f}   True negatives  {tn:7.0f}")
print(f"P(disease | positive test) = {tp / (tp + fp) * 100:.1f}%")
print(f"P(healthy | negative test) = {tn / (tn + fn) * 100:.2f}%")
OUTPUT
True positives 900 False negatives 100 False positives 4950 True negatives 94050 P(disease | positive test) = 15.4% P(healthy | negative test) = 99.89%

Optional stopping inflates Type I errorsOptional stopping, Type I errors बढ़ाता है可选停止会抬高第一类错误

import numpy as np
from scipy import stats

# Optional stopping: peek after every 10 people (up to 100), stop as soon as p < 0.05
rng = np.random.default_rng(11)
reps, hits = 10_000, 0
for _ in range(reps):
    x = rng.normal(0, 1, 100)                   # H₀ is TRUE
    for n in range(10, 101, 10):
        if stats.ttest_1samp(x[:n], 0).pvalue < 0.05:
            hits += 1
            break
print(f"Fixed n = 100, one test:        5.0% false positives (by design)")
print(f"Peeking 10 times, stop if p<.05: {hits / reps * 100:.1f}% false positives")
OUTPUT
Fixed n = 100, one test: 5.0% false positives (by design) Peeking 10 times, stop if p<.05: 19.8% false positives

SectionSection第 14 节

Quick Reference Summaryझटपट सारांश速查总结

FeatureFeature特征Type I errorType I error第一类错误Type II errorType II error第二类错误
Also calledदूसरा नाम又称False positive, α errorFalse positive, α error假阳性,α 错误False negative, β errorFalse negative, β error假阴性,β 错误
Definitionपरिभाषा定义Reject H₀ when H₀ is trueH₀ सच होने पर reject करनाH₀ 为真时拒绝Keep H₀ when H₀ is falseH₀ ग़लत होने पर रखनाH₀ 为假时保留
ProbabilityProbability概率α (if H₀ is true)α (अगर H₀ सच)α(若 H₀ 为真)β (depends on n, effect size, σ, α)β (n, effect size, σ, α पर निर्भर)β(取决于 n、效应量、σ、α)
Medical nameMedical नाम医学术语1 − specificity1 − specificity1 − 特异度1 − sensitivity1 − sensitivity1 − 灵敏度
Courtroomअदालत法庭Convicting the innocentबेगुनाह को सज़ा给无辜者定罪Freeing the guiltyदोषी को छोड़ना放走罪犯
Smoke detectorSmoke detector烟雾报警器Beeps, no fireबजता है, आग नहीं响了,却没火Silent in a fireआग में चुप着火了,却不响
Reduced byघटता है如何降低Lowering αα घटाकर降低 αBigger n, less noise, or a higher αबड़ा n, कम शोर, या ऊँचा α更大 n、更少噪声或更高 α
Trade-offसौदा权衡For a fixed test and n, lowering one raises the otherतय test और n पर, एक घटाने से दूसरा बढ़ता है检验和 n 固定时,降低一个就会升高另一个Better evidence (bigger n) lowers bothबेहतर सबूत (बड़ा n) दोनों घटाता है更好的证据(更大的 n)能同时降低两者
🧮
The Analyst's CreedAnalyst का सिद्धांत分析师信条

Good statistical thinking is not about getting p < 0.05. It is about honestly measuring and limiting both kinds of error for the decision at hand. Always ask: "In this situation, which error costs more?" Control that error first, plan enough power to control the other, and report both openly.

अच्छी statistical सोच p < 0.05 पाने के बारे में नहीं है। यह सामने के फ़ैसले के लिए दोनों तरह की ग़लतियों को ईमानदारी से मापने और सीमित करने के बारे में है। हमेशा पूछें: "इस स्थिति में कौन-सी ग़लती ज़्यादा महँगी है?" पहले उस error को नियंत्रित करें, दूसरी को नियंत्रित करने के लिए काफ़ी power की योजना बनाएँ, और दोनों को खुलकर बताएँ।

好的统计思维不是为了得到 p < 0.05,而是针对眼前的决定,诚实地衡量并控制两类错误。始终问自己:“在这种情况下,哪种错误代价更高?”先控制那种错误,再规划足够的检验力来控制另一种,并公开报告两者。

You have completed Inferential Statistics. View all sections →