Sunday 6 September 2026

Quant interview

Tilting the Gaussian to price a rare event

medium · Monte Carlo variance reduction

Let Z~N(0,1) and let a=3. We want a Monte Carlo estimate of the tail probability p=ℙ(Z≥a)=Φ¯(a), where ϕ and Φ denote the standard normal density and CDF and Φ¯=1−Φ.

The crude estimator draws Z1,…,Zn~N(0,1) and averages the indicators 1{Zi≥a}. Because p is small this is wasteful. Instead use importance sampling: draw X1,…,Xn from a shifted proposal N(μ,1) with density gμ(x)=ϕ(x−μ), and reweight.

  1. Write down the importance-sampling estimator of p using proposal N(μ,1), and show it is unbiased for every μ. State its likelihood ratio (weight) explicitly.

  2. Show that the second moment of one reweighted sample equals M(μ)=eμ2Φ¯(a+μ), and deduce the equation satisfied by the variance-minimizing shift μ⋆.

  3. For a=3, find μ⋆ numerically and report the factor by which the per-sample variance is reduced relative to the crude estimator. Use p=Φ¯(3)=1.3499×10−3.

Solution

The estimator and its unbiasedness

Write the target as an expectation under the proposal by inserting the likelihood ratio ϕ(x)/gμ(x): p=∫a∞ϕ(x)dx=∫a∞ϕ(x)ϕ(x−μ)ϕ(x−μ)dx=𝔼X~N(μ,1)[w(X)1{X≥a}].

The weight is the ratio of the two Gaussian densities, w(x)=ϕ(x)ϕ(x−μ)=exp(−12x2+12(x−μ)2)=e−μx+μ2/2.

The estimator is p^μ=1n∑i=1nw(Xi)1{Xi≥a},Xi~N(μ,1), and 𝔼[p^μ]=p by the change of measure above, for every μ. Unbiasedness never depends on μ; only the variance does.

The second moment collapses to a shifted tail

The per-sample variance is M(μ)−p2 with M(μ)=𝔼X~N(μ,1)[w(X)21{X≥a}]=∫a∞ϕ(x)2ϕ(x−μ)dx.

The key algebraic step — the one a candidate typically fumbles — is to complete the square in the integrand rather than fight the integral numerically. With ϕ(x)=12πe−x2/2, ϕ(x)2ϕ(x−μ)=12πexp(−x2+12(x−μ)2).

The exponent is −x2+12x2−μx+12μ2=−12x2−μx+12μ2=−12(x+μ)2+μ2.

Hence ϕ(x)2ϕ(x−μ)=eμ2ϕ(x+μ), and integrating from a to ∞ gives M(μ)=eμ2∫a∞ϕ(x+μ)dx=eμ2Φ¯(a+μ).

Minimizing M is easiest through lnM(μ)=μ2+lnΦ¯(a+μ): ddμlnM(μ)=2μ−ϕ(a+μ)Φ¯(a+μ)=0.

So the optimal shift solves 2μ⋆=ϕ(a+μ⋆)Φ¯(a+μ⋆)=h(a+μ⋆) where h is the Gaussian hazard rate. Since M is convex in this sense (the hazard rate is increasing, so the derivative crosses zero once), this stationary point is the global minimum.

Solving for a=3 and the variance gain

Use the Mills-ratio expansion h(t)=ϕ(t)/Φ¯(t)≈t+1/t−2/t3 for large t. With t=a+μ=3+μ, the fixed point 2μ=h(3+μ) gives, iterating, μ⋆≈3.15,t⋆=a+μ⋆≈6.15.

Note the heuristic ''shift the proposal mean up to the threshold'' (μ≈a) is almost right; the exact optimum sits just above a because the tail mass beyond a concentrates slightly past it.

Now evaluate the variances.

The variance reduction factor is 1.348×10−36.08×10−6≈2.2×102.

Answer. 1. p^μ=1n∑ie−μXi+μ2/21{Xi≥a} with Xi~N(μ,1); unbiased for all μ. 2. M(μ)=eμ2Φ¯(a+μ), and μ⋆ solves 2μ⋆=ϕ(a+μ⋆)/Φ¯(a+μ⋆). 3. For a=3: μ⋆≈3.15, giving roughly a 220-fold reduction in per-sample variance (equivalently, about 220× fewer draws for the same accuracy).

Note

The zero-variance ideal proposal is the conditional density g⋆(x)=ϕ(x)1{x≥a}/p, i.e. the normal truncated to the tail — but it requires knowing p and is awkward to sample, which is exactly why the tractable single-parameter tilt is used. Also worth knowing: antithetic variates would help almost nothing here, because the payoff 1{Z≥3} is essentially never triggered by both Z and −Z; the pairing gives you two zeros nearly always. Rare-event estimation is the textbook case where importance sampling wins and antithetics do not.

Statistics in machine learning

The price of forgetting: mutual information and generalization

hard · PAC-Bayes and information-theoretic generalization bounds

Fix a data space Z, a hypothesis space W, and a loss ℓ:W×Z→R. Let S=(Z1,…,Zn) be i.i.d.\ from a distribution D on Z. A (possibly randomized) learning rule is a Markov kernel PW∣S producing a hypothesis W∈W; write PW,S for the resulting joint law and PW,PS for its marginals. Define LD(w)=EZ~D[ℓ(w,Z)],LS(w)=1n∑i=1nℓ(w,Zi). Assume that for every fixed w∈W the random variable ℓ(w,Z), Z~D, is σ-sub-Gaussian, i.e. logE[eλ(ℓ(w,Z)−LD(w))]≤λ2σ22for all λ∈R. Let I(W;S)=D(PW,S\|PW⊗PS) denote the mutual information.

(a) Prove that |EPW,S[LD(W)−LS(W)]|≤2σ2nI(W;S). Name the variational identity that drives the proof, and point out the one step that centers the relevant quantity.

(b) Suppose S has an absolutely continuous law on RN (N=ndimZ) and the rule is deterministic, W=f(S) for measurable f, with pushforward law PW atomless (non-degenerate). Show I(W;S)=+∞, so the bound of (a) is vacuous for every deterministic rule with a continuously distributed output. Say in one sentence which inequality from your proof of (a) is responsible.

(c) Take D=N(μ,1) on R and the noisy mean estimator W=Z¯n+ξ, where Z¯n=1n∑iZi and ξ~N(0,τ2) is independent of S.

  (i) Compute I(W;S) exactly.

  (ii) Write the resulting bound from (a) and describe its behaviour as τ→0+; reconcile with (b).

  (iii) With σ=1, find the smallest τ for which the bound is at most 1/n, and interpret the required noise scale.

Solution

(a) The mutual-information bound

Define F(w,s)=LD(w)−1n∑iℓ(w,zi), so the target is EPW,S[F(W,S)].

The identity that does the work is the Donsker–Varadhan variational formula for relative entropy: for any two probability measures P≪P¯ and any measurable g with EP¯[eg]<∞, EP[g]≤D(P‖P¯)+logEP¯[eg]. Apply it with P=PW,S, P¯=PW⊗PS, and g=λF(W,S) for λ>0. Since D(PW,S‖PW⊗PS)=I(W;S), λEPW,S[F]≤I(W;S)+logEPW⊗PS[eλF].

The step a candidate misses is that the product measure both centers F and factorizes it. Under P¯=PW⊗PS, condition on W=w; then S is still i.i.d.\ D and independent of w, and F(w,S)=−1n∑i=1n(ℓ(w,Zi)−LD(w)) is a centered average of n i.i.d.\ σ-sub-Gaussian terms. Its MGF factorizes: ES[eλF(w,S)]=∏i=1nE[e−λn(ℓ(w,Zi)−LD(w))]≤∏i=1neλ2σ2/(2n2)=eλ2σ2/(2n). Averaging over w~PW preserves the bound, so logEP¯[eλF]≤λ2σ2/(2n). (In particular EP¯[F]=0: under the product law the empirical risk is unbiased for the population risk of an independent hypothesis.) Hence λEPW,S[F]≤I(W;S)+λ2σ22n,i.e.EPW,S[F]≤I(W;S)λ+λσ22n. Minimizing the right side over λ>0 at λ⋆=2nI(W;S)/σ2 gives E[F]≤2σ2I(W;S)/n. Repeating with λ<0 (equivalently applying the argument to −F) gives the matching lower bound, so |EPW,S[LD(W)−LS(W)]|≤2σ2nI(W;S).∎

(b) Deterministic rules have infinite mutual information

Let G={(f(s),s):s∈RN}⊂W×RN be the graph. Because W=f(S) deterministically, PW,S(G)=1. Under the product law, (PW⊗PS)(G)=∫RNPW({f(s)})dPS(s)=0, since PW is atomless, so PW({w})=0 for every point w. Thus PW,S assigns full mass to a set of product-measure zero: PW,S⧸≪PW⊗PS, and by definition of relative entropy I(W;S)=D(PW,S‖PW⊗PS)=+∞. The bound of (a) then reads |gap|≤∞: vacuous, even though for, say, a bounded loss the true gap is O(1/n).

Responsible step: the Donsker–Varadhan inequality itself. It compares PW,S against PW⊗PS, and this comparison is infinitely loose precisely when the joint law is mutually singular with the product — i.e.\ when the hypothesis is a deterministic function of continuous data. The moral: mutual information is only an upper bound mechanism; a finite gap forces neither finite I(W;S) nor tightness, which is why one randomizes the algorithm (or passes to conditional-mutual-information/CMI frameworks that stay finite by construction).

(c) The noisy mean estimator

(i) The estimator depends on S only through the sufficient statistic Z¯n, and ξ⟂S, so S→Z¯n→W is a Markov chain and W⟂S∣Z¯n. Hence I(W;S)=I(W;Z¯n)+I(W;S∣Z¯n)⏟=0=I(W;Z¯n). Now Z¯n~N(μ,1/n) and W=Z¯n+ξ with ξ~N(0,τ2) is a scalar additive-Gaussian channel with input variance 1/n and noise variance τ2: I(W;S)=12log(1+1/nτ2)=12log(1+1nτ2).

(ii) Substituting into (a), |gap|≤2σ2n·12log(1+1nτ2)=σ1nlog(1+1nτ2). As τ→0+ the argument of the log diverges and the bound →∞ — exactly the deterministic-ERM pathology of (b): plain W=Z¯n is a continuous deterministic function of the data, so I(W;S)=∞.

(iii) With σ=1 require 1nlog(1+1nτ2)≤1n, i.e. log(1+1nτ2)≤1, i.e. 1nτ2≤e−1. The smallest admissible noise is τmin=1n(e−1)≈0.763n. The required injected noise has standard deviation Θ(1/n) — the same order as the sampling fluctuation of Z¯n itself (whose s.d.\ is 1/n). To certify even a 1/n generalization bound by the information method, you must blur the estimator by an amount comparable to the signal you extracted; here that roughly doubles the estimator's variance. Information-theoretic control literally charges you for the precision with which the output remembers the sample.

Closing notes


Two new problems every morning at 8am · every day so far