WorksComputer Science
Revisiting Generalized Median Estimators: Exact Bitwise Computation and Gray Code Acceleration
Abstract
Generalized median estimators evaluate the median of a symmetric kernel over all subsets of size . Exhaustive evaluation was considered impractical even for (), prompting stochastic subsampling (Wilde and Grimshaw, 2013). We show that this barrier is computational, not combinatorial: storing all subsets requires space, whereas stateful enumeration uses auxiliary state and retains only kernel values. We combine two exhaustive traversals with three-way Quickselect and a deterministic median-of-medians fallback, giving worst-case selection. Gosper's successor takes kernel work per subset for ; a Revolving Door Gray code changes one element out and one in, enabling kernel updates between recalibrations and total time. We derive floating-point error bounds for the location () and mean-centered sample variance () kernels and their resulting median. For , our ANSI C implementation evaluates all subsets in ms and ms, respectively. A direct C sweep places the crossover with partial lexicographic unranking at approximately - subsets (- of ), below the - subsets required by Wilde and Grimshaw's sequential approximation at .