Conditioning, Bayesian inference and sampling error
Introduced| English | Meaning |
|---|---|
| standard error/ˈstændəd ˈerə/ | The standard deviation of a statistic's sampling distribution, often estimated from a sample. |
| sensitivity/ˌsensɪˈtɪvɪti/ | The probability of a positive result given presence of the condition. |
| specificity/ˌspesɪˈfɪsɪti/ | The probability of a negative result given absence of the condition. |
A positive test, a rare condition
- A model test is 90% sensitive and 95% specific; 2% of a population have the condition. Among people testing positive, only about 27% have it. A high detection rate answers a different question from the chance that a positive is correct.
- We will track the population after conditioning, then distinguish the spread of observations from the standard error 标准误 of their mean. Test rates below are hypothetical mathematical inputs.
Conditioning changes the denominator
- For events $A,B$ with $P(B)>0$, define $P(A\mid B)=\dfrac{P(A\cap B)}{P(B)}$. The denominator restricts attention to $B$; the numerator keeps outcomes that also satisfy $A$. The elementary formula does not define conditioning on a zero-probability event.
- Roll a fair die. Let $A=\{4,5,6\}$ and $B=\{2,4,6\}$. Then $P(A\cap B)=2/6$ and $P(B)=3/6$, giving $P(A\mid B)=2/3$. The unconditional probability $P(A)=1/2$ uses all six outcomes.
$P(A \cap B) = 0.12$ and $P(B) = 0.3$. Find $P(A \mid B)$.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
P(A | B) = P(A ∩ B) / P(B) = 0.12 / 0.3 = 0.4.
Multiply along a conditional path
- Rearranging the definition gives $P(A\cap B)=P(B)P(A\mid B)$. For three events, start with $P(A)$, then multiply by $P(B\mid A)$ and $P(C\mid A\cap B)$. Each conditioning event must have positive probability.
- Draw two cards without replacement from a standard 52-card deck. The probability of two aces is $\dfrac4{52}\cdot\dfrac3{51}=\dfrac1{221}$. After one ace, only three aces remain among 51 cards. Multiplying two unchanged probabilities would assume independence that is absent.
A first card drawn from a standard 52-card deck is an ace and is not replaced. Find the probability the second is an ace, to three decimal places.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
Three aces remain among 51 cards, so the conditional probability is 3/51=1/17≈0.059.
Independence is an exact identity
- Events are independent when $P(A\cap B)=P(A)P(B)$. If $P(B)>0$, this is equivalent to $P(A\mid B)=P(A)$. The product definition still works if either event has probability zero.
- With $P(A)=0.4$, $P(B)=0.5$, and $P(A\cap B)=0.3$, the conditional probability is $0.6$, so the events are dependent. In contrast, marginals $0.5$ and $0.4$ with intersection $0.2$ satisfy independence exactly.
If $P(A) = 0.5$, $P(B) = 0.4$ and $P(A \cap B) = 0.2$, then $A$ and $B$ are independent.
Difficulty 1/5 · 100 coins + a small bonus on first completion today
True. A and B are independent exactly when P(A ∩ B) = P(A)P(B), and 0.5 × 0.4 = 0.2.
Disjoint does not mean independent
- Disjoint events have $A\cap B=\varnothing$. If both have positive probability, they cannot be independent: the intersection has probability zero but the product is positive. On a fair die, “odd” and “even” are disjoint and dependent.
- Independence of every pair need not give mutual independence. For two fair independent coin tosses, let $A$ mean first toss heads, $B$ mean second toss heads, and $C$ mean the tosses agree. Every pair has intersection probability $1/4$. The triple also has probability $1/4$, whereas mutual independence would require $1/8$.
Two disjoint events, each with positive probability, can be independent.
Difficulty 1/5 · 100 coins + a small bonus on first completion today
Their intersection has probability zero but the product of their probabilities is positive.
For a fair die, let $A=\{4,5,6\}$ and $B=\{2,4,6\}$. Find the intersection and both conditional probabilities. Are the events independent or disjoint?
Check the conditioning group, assumptions and arithmetic against the model.
Add across a complete partition
- If events $B_1,\ldots,B_k$ are disjoint, cover the sample space, and each has positive probability, then $P(A)=\sum_i P(B_i)P(A\mid B_i)$. Each term is one disjoint route into $A$; no outcome is omitted or counted twice.
- A factory gets 60% of parts from line 1 and 40% from line 2. Their defect rates are 1% and 3%. The overall defect probability is $0.6(0.01)+0.4(0.03)=0.018$, not the unweighted average $0.02$.
Name the test rates carefully
- Let $D$ mean the condition is present and $+$ mean a positive result. Sensitivity 灵敏度 is $P(+\mid D)$; specificity 特异度 is $P(-\mid\bar D)$. The false-positive rate is $P(+\mid\bar D)=1-\text{specificity}$.
- The positive predictive probability is $P(D\mid +)$, which conditions on a different group. Neither sensitivity nor specificity alone gives this probability; the base rate $P(D)$ also matters.
Build all four cells
- In a model population of 10,000, the 2% base rate gives 200 with the condition and 9,800 without it. Sensitivity 90% gives 180 true positives and 20 false negatives. Specificity 95% gives 9,310 true negatives and 490 false positives.
- There are $180+490=670$ positive results and $20+9310=9330$ negative results. Thus $P(D\mid +)=180/670\approx26.9\%$. The 90% detection rate is $180/200$, using a different denominator.
The given group changes the denominator
$P(A\mid B)=n(A\cap B)/n(B),\quad n(B)>0$
Use the lesson’s table to compare a conditional probability, its reverse and a whole-cohort probability. The highlighted group is the denominator.
Bayes reverses the conditioning
- Write $u=P(D)P(+\mid D)$ and $v=P(\bar D)P(+\mid\bar D)$. Total probability gives $P(+)=u+v$. If this is positive, Bayes' theorem gives $P(D\mid +)=\dfrac{u}{u+v}$.
- For base rate 10%, sensitivity 80%, and specificity 90%, the two positive routes are $u=0.10(0.80)=0.08$ and $v=0.90(0.10)=0.09$. The posterior is $0.08/0.17=8/17\approx0.471$, rather than the sensitivity $0.8$.
Which probability is it?
Name the conditional probability a statement describes.
Prevalence 10%, sensitivity 80%, specificity 90%. Find $P(D \mid +)$ to three decimal places.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
The positive routes are 0.10×0.80=0.08 and 0.90×0.10=0.09, so the posterior is 0.08/(0.08+0.09)=8/17≈0.471.
Change the base rate, keep the test
- Keep sensitivity 90% and specificity 95%, but raise the base rate from 2% to 20%. Per 10,000 people, the positive counts become 1,800 true positives and 400 false positives. Now $P(D\mid +)=1800/2200\approx81.8\%$.
- The test's two conditional rates stayed fixed; the mixture of people changed. Conversely, with the base rate at 2%, raising specificity to 99% reduces false positives to 98 and gives $180/278\approx64.7\%$.
In a hypothetical batch, 4% of parts are defective. A checker flags 95% of defective parts and 2% of nondefective parts. Build a table for 10,000 parts and find the probability a flagged part is defective.
Check the conditioning group, assumptions and arithmetic against the model.
Negative results and repeated results
- In the original 2% model, $P(D\mid -)=20/9330\approx0.00214$. Its complement is $P(\bar D\mid -)$, not $P(D\mid +)$: both probabilities in a complement must condition on the same event.
- Repeating a test does not automatically square its error rate. Squaring the false-positive rate requires independence of the two results conditional on absence of the condition; multiplying sensitivities likewise requires conditional independence given its presence. Shared error sources can violate these assumptions.
In the original hypothetical 2% model, 20 of the 9,330 negative results have the condition. Find the probability of the condition given a negative result, to six decimal places.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
The negative result defines the denominator: 20/9330≈0.002144. This is not the false-negative rate 20/200.
When can two test false-positive rates of 0.05 be multiplied to obtain a joint false-positive rate of 0.0025?
Difficulty 1/5 · 100 coins + a small bonus on first completion today
The multiplication is within the group without the condition, so independence must hold conditional on absence, with each conditional rate 0.05. Merely using the same test or a new day does not establish it.
A mean has its own distribution
- Before sampling, observations $X_1,\ldots,X_n$ and their mean $\bar X$ are random variables. Repeating the sampling procedure gives a sampling distribution of possible means. Its standard deviation is the standard error of the mean.
- If every observation has mean $\mu$, linearity gives $E(\bar X)=\mu$; independence is not needed for this expectation. A realized sample mean $\bar x$ is one value, not the whole sampling distribution.
Derive the standard error
- Let $\bar X=\frac1n\sum_iX_i$. Suppose the observations are independent and each has finite variance $\sigma^2$. Their sum has variance $n\sigma^2$; averaging divides this by $n^2$. Thus $\operatorname{Var}(\bar X)=\sigma^2/n$, and taking the square root gives $\operatorname{SE}(\bar X)=\dfrac{\sigma}{\sqrt n}$.
- Independent, identically distributed observations with finite variance satisfy these assumptions, but normality is unnecessary for the variance identity. For unequal independent variances, use their sum divided by $n^2$ before taking the square root.
Observation spread versus mean spread
- With $\sigma=12$, the mean of 36 independent observations has SE $2$, and the mean of 144 has SE $1$. Individual observations still have standard deviation $12$. A larger sample stabilizes the mean, rather than making each observation less variable.
- If $\sigma$ is unknown, estimate SE by $s/\sqrt n$, where $s$ is the sample standard deviation. For $s=18$ and $n=81$, the estimate is $2$. It is an estimate from data, not a known population value.
Individual spread and sample-mean spread
$\mathrm{SD}(\bar X)=\sigma/\sqrt n$
Changing n changes the standard error, not the population standard deviation. Normal probabilities require an explicit distribution model.
Each of 100 independent observations has standard deviation $\sigma=20$. What is the standard error of their mean?
Difficulty 2/5 · 140 coins + a small bonus on first completion today
The standard error of the mean is σ/√n = 20/√100 = 20/10 = 2.
For an iid sample of size $81$ with sample standard deviation $s=18$, estimate the standard error of the sample mean.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
Use s/√n=18/9=2. This estimates the unknown population SE.
Plan the sample size
- Holding the observation variance and sampling assumptions fixed, multiplying $n$ by $k$ multiplies SE by $1/\sqrt k$. Quadrupling the sample halves SE; reducing SE to one third requires nine times as many observations.
- To achieve SE at most $e>0$ when $\sigma$ is known, require $n\ge(\sigma/e)^2$ and round up to an integer. With $\sigma=10$ and target SE $3$, this gives $n\ge100/9$, so the minimum is $12$, not $11$.
Holding the common observation variance fixed for independent observations, multiplying the sample size by 4 changes the mean standard error by a factor of
Difficulty 1/5 · 100 coins + a small bonus on first completion today
√4 = 2 in the denominator.
Independent observations have common standard deviation $\sigma=10$. What is the smallest integer sample size giving mean SE at most $3$?
Difficulty 2/5 · 140 coins + a small bonus on first completion today
n must be at least (10/3)²=100/9≈11.111; round up to 12. At n=11 the SE is still larger than 3.
Two independent observations have the same mean $\mu$ and variances $9$ and $16$. Find the mean and standard error of their average. Explain why a common-$\sigma$ shortcut is inappropriate.
Check the conditioning group, assumptions and arithmetic against the model.
Exact spread is not exact normality
- Independent normal observations give a normal sample mean at every sample size. For iid observations with finite positive variance, the central limit theorem instead gives an approximately normal standardized mean as $n$ grows; it does not make the observations normal.
- A mean of $n$ independent Bernoulli observations can take only $n+1$ values, so it is not exactly normal. The SE formula still holds. There is no universal sample size that guarantees an accurate normal approximation for every population.
The mean of any finite iid sample with finite variance has an exactly normal distribution.
Difficulty 1/5 · 100 coins + a small bonus on first completion today
For Bernoulli observations a finite sample mean is discrete. The standard error identity can be exact while a normal approximation is only approximate.
Dependence and bias need separate checks
- For dependent observations, variance includes covariance terms. For two observations with variance $\sigma^2$ and covariance $c$, the mean has variance $(\sigma^2+c)/2$. If the second repeats exactly the same random reading, $c=\sigma^2$: averaging them gives no variance reduction.
- Small SE measures sampling spread, not bias. A sensor that always adds $3$ to otherwise unbiased readings gives a mean biased by $3$, however large the sample. More repeated readings do not remove that systematic offset or repair an unrepresentative sample.
Which quantity changes?
Separate observation spread, sampling spread and bias.
Suppose $X_i=\mu+3+Z+\varepsilon_i$, where $Z$ has mean zero and variance 4, the $\varepsilon_i$ are independent with mean zero and variance 9, and $Z$ is independent of every error. Find the mean and variance of $\bar X$ and describe what increasing $n$ can fix.
Check the conditioning group, assumptions and arithmetic against the model.
Recap
- sensitivity: The probability of a positive result given presence of the condition.
- specificity: The probability of a negative result given absence of the condition.
- standard error: The standard deviation of a statistic's sampling distribution. For an independent common-variance sample mean it is $\sigma/\sqrt n$; $s/\sqrt n$ estimates it when $\sigma$ is unknown. Check dependence, approximation assumptions and bias separately.