Conditional Probability, Bayes' Theorem, Expectation, and the Normal Distribution TODO
Concept
Conditional probability P(A|B) is the probability of A given that B has occurred, defined as P(A and B) divided by P(B). Bayes' theorem, P(A|B) = P(B|A)P(A)/P(B), gives the procedure for updating a prior probability with the likelihood of new evidence to get a posterior probability. Expectation is a probability-weighted average, and by linearity the expectation of a sum equals the sum of expectations even when the variables aren't independent — though variance only adds simply when the variables are uncorrelated. The normal distribution is determined entirely by its mean and variance, and it serves as the default model because of the central limit theorem: summing many independent random variables with finite variance produces a sum whose distribution approaches normal. That said, assuming normality for fat-tailed data — like financial returns — badly underestimates the probability of extreme events.
When the base rate is low, even a highly accurate detector produces mostly false positives among its positive calls — a Bayesian conclusion that overturns naive intuition in practice — and a prediction market's price is itself best read as a posterior probability.
Code & Formula
# Day 35 — 조건부확률·베이즈·기대값·정규분포
# 질병 검사 예시로 베이즈 정리를 수치로 계산: P(질병|양성) = P(양성|질병)P(질병) / P(양성)
prior_disease = 0.01 # P(질병) — 사전확률(유병률)
p_positive_given_disease = 0.95 # P(양성|질병) — 민감도
p_positive_given_healthy = 0.05 # P(양성|건강) — 위양성률
p_healthy = 1 - prior_disease
p_positive = (p_positive_given_disease * prior_disease
+ p_positive_given_healthy * p_healthy)
p_disease_given_positive = (p_positive_given_disease * prior_disease) / p_positive
print(f"사전확률 P(질병) = {prior_disease}")
print(f"P(양성) (전체확률) = {p_positive:.4f}")
print(f"베이즈 정리로 계산한 P(질병|양성) = {p_disease_given_positive:.4f}")
print("-> 검사가 정확해 보여도 유병률이 낮으면 사후확률은 여전히 낮다는 직관을 확인한다.\n")
# 기대값과 정규분포: 표준정규분포에서 표본을 뽑아 표본평균이 이론적 기대값(0)에 가까워짐을 확인
import random
random.seed(42)
n = 100_000
samples = [random.gauss(mu=0, sigma=1) for _ in range(n)]
sample_mean = sum(samples) / n
sample_var = sum((s - sample_mean) ** 2 for s in samples) / n
print(f"N(0,1)에서 {n}개 표본 추출")
print(f"표본평균 = {sample_mean:.6f} (이론값 0)")
print(f"표본분산 = {sample_var:.6f} (이론값 1)")
Exercise
For an event with a 1% base rate, detected by a test with 99% sensitivity and 99% specificity, compute by hand the probability that a positive result is actually correct, then verify it with 100,000 simulation runs.
Practical Connection
Verex's market prices are read as participants' posterior probability estimates, and LMSR's per-outcome prices are always maintained as a probability vector summing to 1 — so getting this probabilistic language exactly right is what keeps P&L and settlement calculations from going wrong.
If you study this on a given day, add a note link and a ✅ to this line in the source curriculum (docs/knowledge/math-50-curriculum.md) and this spot will lead straight to the note body. You can also write directly on this page — but regenerating overwrites it, so it's safer to keep anything you want to save as markdown under docs/algorithms/.