Quant Practice · Vol. I 宽客练习集 · 卷一

You can you up.

你也行

Four problems. Hidden answers. No company name attached. Frame the model, name the theorem, then compute — that's what they actually grade you on. 四道题. 答案默认折叠. 不挂任何公司名. 设模型, 报定理, 再算数 — 这才是面试官真正打分的地方.

Set题集 · 01 Topics主题 · Probability · Statistics · Finance概率 · 统计 · 金融 Difficulty难度 · ★★★☆☆
Markov Chain马尔可夫链 Total Expectation全期望 Recurrence递推关系

Expected tosses to get HHH (and $n$ heads in a row) 抛出 HHH 的期望次数 (推广到 $n$ 个连续正面)

Problem题目

A fair coin is tossed repeatedly until the sequence $\text{HHH}$ (three heads in a row) appears. What is the expected number of tosses? Generalize to $n$ consecutive heads.

反复抛一枚均匀硬币, 直到出现 $\text{HHH}$ (连续三个正面). 期望抛掷多少次? 并将结果推广到 $n$ 个连续正面.

The "every fail resets you" trick"一次反面就清零" 的小技巧

Let $E_n$ be the expected number of tosses to get $n$ heads in a row. Suppose you've already managed to get $n-1$ heads in a row (which took $E_{n-1}$ tosses on average). You toss one more coin:

设 $E_n$ 为得到 $n$ 个连续正面的期望抛掷次数. 假设你已经成功抛出 $n-1$ 个连续正面 (平均花费 $E_{n-1}$ 次). 再抛一次:

  • With probability $\tfrac{1}{2}$: it's H → done in $E_{n-1}+1$ tosses.
  • With probability $\tfrac{1}{2}$: it's T → you've used $E_{n-1}+1$ tosses and you're back at zero, so you need $E_n$ more.
  • 概率 $\tfrac{1}{2}$: 正面 → 总共 $E_{n-1}+1$ 次完成.
  • 概率 $\tfrac{1}{2}$: 反面 → 已用 $E_{n-1}+1$ 次, 但回到起点, 还需 $E_n$ 次.
Take expectations取期望
$$E_n = \tfrac{1}{2}(E_{n-1}+1) + \tfrac{1}{2}(E_{n-1}+1+E_n)$$

Simplify:化简:

$$E_n = E_{n-1} + 1 + \tfrac{1}{2}E_n \;\;\Longrightarrow\;\; E_n = 2E_{n-1} + 2$$

With $E_0 = 0$:由 $E_0 = 0$:

$n$1234general通项
$E_n$261430$2^{n+1}-2$
For HHH: $E_3 = 2^4 - 2 = \mathbf{14}$ tosses. HHH 的答案: $E_3 = 2^4 - 2 = \mathbf{14}$ 次.

Why this beats the full state machine为什么比完整状态机更直观

The key observation: a tails always sends you back to state 0, no matter where you are. So you only track "how many H in a row do I currently have," and the recurrence collapses to one line. No 4-state system, no linear algebra.

关键观察: 反面永远把你打回状态 0, 不管你已连了几个正. 所以只需跟踪"当前连了几个正", 递推关系一行就能写完. 不需要 4 状态系统, 也不需要线性代数.

Sanity check · biased coin验证 · 偏置硬币

For probability $p$ of heads, the same logic gives $E_n = \dfrac{1-p^n}{p^n(1-p)}$. With $p=\tfrac{1}{2}$, $n=3$: $\dfrac{7/8}{1/16} = 14$. ✓

若正面概率为 $p$, 同样逻辑给出 $E_n = \dfrac{1-p^n}{p^n(1-p)}$. 代入 $p=\tfrac{1}{2}$, $n=3$: $\dfrac{7/8}{1/16} = 14$. ✓

Geometric Probability几何概率 Law of Large Numbers大数定律 Monte Carlo蒙特卡洛

Estimate $\pi$ via Monte Carlo 蒙特卡洛 估计 $\pi$

Problem题目

Design a Monte Carlo simulation that estimates the value of $\pi$. How would you implement the "is the point inside the circle" check?

设计一个蒙特卡洛模拟来估计 $\pi$ 的值. 如何实现 "判断点是否在圆内"?

Setup设置

Inscribe a quarter unit circle inside the unit square $[0,1]\times[0,1]$.

在单位正方形 $[0,1]\times[0,1]$ 内嵌一个四分之一单位圆.

  • Area of square: $1$
  • Area of quarter circle: $\dfrac{\pi}{4}$
  • 正方形面积: $1$
  • 四分之一圆面积: $\dfrac{\pi}{4}$

Random point & membership test随机点与判定

Draw $X \sim U(0,1)$ and $Y \sim U(0,1)$ independently. The point $(X,Y)$ lies inside the quarter circle iff its distance from the origin is $\leq 1$, i.e.

独立取 $X \sim U(0,1)$ 与 $Y \sim U(0,1)$. 点 $(X,Y)$ 在四分之一圆内当且仅当其到原点距离 $\leq 1$, 即

$$X^2 + Y^2 \leq 1$$

(No square root needed — squaring both sides keeps it cheap.)

(不需要开平方 — 两边平方后判断更省算力.)

Estimator估计量

Run $N$ trials. Let $K$ be the number of points satisfying $X^2+Y^2 \leq 1$. Then by LLN:

运行 $N$ 次试验. 设 $K$ 为满足 $X^2+Y^2 \leq 1$ 的点数. 由大数定律:

$$\frac{K}{N} \xrightarrow{N\to\infty} \frac{\pi}{4} \quad\Longrightarrow\quad \hat{\pi} = 4 \cdot \frac{K}{N}$$

Convergence rate (good follow-up to mention)收敛速度 (面试加分点)

Each trial is Bernoulli with $p = \pi/4$, so $K \sim \text{Bin}(N, \pi/4)$. The standard error is

每次试验是 $p=\pi/4$ 的伯努利, 故 $K \sim \text{Bin}(N, \pi/4)$. 标准误为

$$\text{SE}(\hat\pi) = 4 \sqrt{\frac{p(1-p)}{N}} \approx \frac{1.64}{\sqrt{N}}$$
One extra decimal of accuracy ≈ $100\times$ more samples. Monte Carlo is $O(1/\sqrt{N})$ — slow, but dimension-independent. 多一位精度 ≈ 样本量翻 $100$ 倍. 蒙特卡洛收敛速度为 $O(1/\sqrt{N})$ — 慢, 但与维度无关.

Pseudocode伪代码

import random
N = 1_000_000
K = sum(1 for _ in range(N)
        if random.random()**2 + random.random()**2 <= 1)
pi_hat = 4 * K / N
Binomial二项分布 CLT中心极限定理 68-95-99.7

Probability of ~220 heads in 400 fair flips 400 次抛硬币得到 约 220 次 正面的概率

Problem题目

A fair coin is flipped 400 times. What is the probability of getting 220 heads? Treat both interpretations: "at least 220" and "exactly 220".

一枚均匀硬币抛 400 次. 得到 220 次正面的概率是多少? 分别讨论 "至少 220 次" 与 "恰好 220 次" 两种解读.

Frame the distribution先写出分布

Let $X$ = number of heads. Then $X \sim \text{Bin}(400, 0.5)$ with

设 $X$ = 正面次数. 则 $X \sim \text{Bin}(400, 0.5)$:

$$\mu = np = 200, \quad \sigma^2 = np(1-p) = 100, \quad \sigma = 10$$

The exact $\binom{400}{220}/2^{400}$ is computable but useless in an interview. CLT to the rescue.

精确值 $\binom{400}{220}/2^{400}$ 算得出来但面试时没用. 这时该 CLT 上场.

Standardize标准化

$220$ is $\dfrac{220-200}{10} = 2$ standard deviations above the mean.

$220$ 距离均值 $\dfrac{220-200}{10} = 2$ 个标准差.

By 68-95-99.7, ~95% of mass is in $[-2, 2]$, so each tail has roughly $\dfrac{1-0.95}{2} = 2.5\%$.

由 68-95-99.7 法则, 约 95% 的质量在 $[-2, 2]$ 区间, 因此每条尾巴约 $\dfrac{1-0.95}{2} = 2.5\%$.

Interpretation A — "at least 220 heads"解读 A — "至少 220 次正面"

$$P(X \geq 220) \approx P(Z \geq 2) \approx \mathbf{2.5\%}$$

More precisely, $\Phi(-2) \approx 2.28\%$.更精确: $\Phi(-2) \approx 2.28\%$.

Interpretation B — "exactly 220 heads"解读 B — "恰好 220 次正面"

Continuity correction: $P(X=220) \approx P(219.5 < X < 220.5) = P(1.95 < Z < 2.05)$. Or use the local normal approximation $P(X=k) \approx \dfrac{1}{\sigma\sqrt{2\pi}} e^{-z^2/2}$ at $z=2$:

连续性修正: $P(X=220) \approx P(219.5 < X < 220.5) = P(1.95 < Z < 2.05)$. 或用局部正态近似 $P(X=k) \approx \dfrac{1}{\sigma\sqrt{2\pi}} e^{-z^2/2}$ ($z=2$):

$$P(X=220) \approx \frac{1}{10\sqrt{2\pi}} \cdot e^{-2} \approx \mathbf{0.54\%}$$

Why "55%" is way off为什么 "55%" 错得离谱

55% only makes sense for $P(X \geq 200)$ — about half. But 220 is meaningfully above the mean: 20 extra heads is twice the standard deviation, deep into the tail. Always anchor on $\mu$ and count $\sigma$ away from it.

55% 只在 $P(X \geq 200)$ 时合理 — 大约一半. 但 220 显著高于均值: 多出 20 次正是 2 倍标准差, 已经深入尾部. 永远先锚定 $\mu$, 再数离它有几个 $\sigma$.

Tail probabilities to memorize必背尾部概率
$z$11.6522.333
$P(Z>z)$16%5%2.5%1%0.13%
Credit Risk信用风险 Loan Pricing贷款定价 EL Framework预期损失框架

Why is credit-card interest higher than mortgage interest? 为什么信用卡利率比 房贷 利率高?

Problem题目

Credit cards typically charge ~20% APR while mortgages run ~6–7%. Explain the gap structurally.

信用卡 APR 通常约 20%, 房贷约 6–7%. 从结构上解释这一利差.

Anchor on the break-even rate先锚定盈亏平衡利率

The bank's break-even rate must cover its expected loss plus costs:

银行的盈亏平衡利率必须覆盖 预期损失 加上各项成本:

$$r \approx r_f + \text{term premium} + \text{credit spread} + \text{op costs} + \text{margin}$$

Where credit spread is driven by

其中信用利差由如下公式驱动:

$$\text{Expected Loss} = \text{PD} \times \text{LGD} \times \text{EAD}$$

PD = probability of default, LGD = loss given default, EAD = exposure at default.

PD = 违约概率, LGD = 违约损失率, EAD = 违约风险敞口.

Side-by-side逐项对比

Factor因素 Mortgage房贷 Credit Card信用卡
Collateral抵押物 Yes — the house有 — 房屋本身 None
LGD ~20–25% (recover via foreclosure)~20–25% (止赎可回收) ~80–100% (basically gone)~80–100% (基本拿不回)
PD Low; full underwriting低; 全面尽调 (收入 / DTI / FICO) Higher; lighter underwriting较高; 尽调宽松, 常被资金紧张者使用
Loan size贷款规模 Large, lumpy大额, 一次性 Small, revolving — high servicing cost / $小额, 循环 — 单位金额服务成本高
Tenor期限 15–30 yrs, fixed cash flows15–30 年, 固定现金流 Open-ended, variable balance开放式, 余额变动
Capital charge (Basel)资本占用 (巴塞尔) Favorable risk weight优惠风险权重 Punitive risk weight惩罚性风险权重
Customer behavior客户行为 Refinance shopping is common普遍比价, 易再融资 Most carriers don't comparison shop大多数持卡人不会比价
Credit cards are unsecured debt with both higher PD and near-100% LGD. Mortgages are collateralized by the house — even on default, the bank recovers most of principal. The rate gap is mostly a credit-spread gap driven by LGD, on top of higher servicing costs and worse capital treatment for unsecured retail credit. 信用卡是 无担保 债务, PD 更高且 LGD 近 100%. 房贷由房屋 担保 — 即使违约, 银行通过止赎也能收回大部分本金. 利差主要来自 LGD 驱动的信用利差, 再加上更高的服务成本和无担保零售信贷更差的资本占用.
Numerical sanity check数值验证

Mortgage: PD = 1%, LGD = 20% → EL = 20 bps

Credit card: PD = 4%, LGD = 90% → EL = 360 bps

→ ~340 bps gap from credit risk alone, before operating costs. That accounts for most of the observed spread.

房贷: PD = 1%, LGD = 20% → EL = 20 bps

信用卡: PD = 4%, LGD = 90% → EL = 360 bps

→ 仅信用风险一项就贡献约 340 bps 利差, 还没算运营成本. 已能解释观察到的大部分利差.

Meta元认知

Cheat sheet — what these are really testing 速查表 — 这些题真正在考你什么

Q题号 Surface topic表面话题 What they actually want他们真正想看到的
Q1 Coin tosses抛硬币 Recursion / first-step analysis递推 / 首步分析
Q2 $\pi$ estimation$\pi$ 估计 Sampling, LLN, convergence rates采样, 大数定律, 收敛速度
Q3 Binomial probability二项概率 CLT instinct when $n$ is large$n$ 大时立刻想到 CLT
Q4 Banking trivia银行常识 First-principles risk pricing从第一性原理出发的风险定价
Common thread: interviewers care about your framing more than the final number. State the model. Name the theorem. Then compute. 共同线索: 面试官在意你的 框架 远胜于最终数字. 先说模型, 再点定理, 最后算数.