The piece revisits importance sampling for Monte Carlo integration, asking which probability density gives the least noisy estimate of an integral. For a function \(f\), sampling from density \(p\) produces the estimator \(f(X)/p(X)\), whose variance depends on how well \(p\) matches the function. Using calculus of variations and a Lagrange multiplier to enforce that \(p\) integrates to one, the derivation finds that the variance-minimizing density is proportional not simply to \(f\), but to its absolute value: \(p(x)=|f(x)|/\int |f|\). The absolute value matters because a probability density cannot be negative, even when the function being integrated changes sign.
The minimum variance is \((\int |f|)^2-(\int f)^2\). Factoring this difference shows it equals four times the product of the total positive contribution and the magnitude of the total negative contribution. Thus, for a nonnegative function, the ideal distribution yields zero variance: every weighted sample gives the same integral. For a sign-changing function, residual noise comes from cancellation between positive and negative regions; the more each contributes relative to the final integral, the larger the minimum variance. The discussion also connects the result to the Cauchy-Schwarz inequality, while emphasizing that variational optimization identifies the minimizing distribution itself, not just a lower bound.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.