paper

A Simple Randomized Estimator for Harmonic Numbers and Logarithms

arXiv:1704.04538

Abstract

Scanning a list of distinct numbers in uniformly random order for its maximum replaces the running maximum times on average, where is the th harmonic number. Run backwards, this gives an estimator: the replacement count of a random list is an unbiased Monte Carlo estimate of , and since , a corrected estimate of . We give the exact variance of the count, an error decomposition with sample-size rules, and an exact sampler of the count using integer draws on average instead of a scan of length . Coupling two counts estimates without , and a binary range reduction then bounds the standard error by for every at fewer than draws per repetition on average. A classical deterministic series on the same reduction reaches the rounding floor with sixteen terms in the reported experiments, quantifying the gap between the two approaches. The purpose is pedagogical: the analysis of an algorithm becomes an estimator of the quantity that analysis produces, with exact variances, finite-sample error bounds, reproducible experiments, and machine-checked algorithm contracts and moment identities. The ingredients are classical; the contribution is their assembly.

arXiv commentv3: substantially revised and extended third version; title changed from "A Simple Randomized Algorithm to Compute Harmonic Numbers and Logarithms". 22 pages, 4 figures, 7 tables. Code, data, and Dafny proofs at https://github.com/alidasdan/randomized-harmonic-logarithms