Revisiting Generalized Median Estimators: Exact Bitwise Computation and Gray Code Acceleration
Robin Nunkesser
Abstract
Generalized median estimators evaluate the median of a symmetric kernel over all M = nk subsets of size k. Exhaustive evaluation was considered impractical even for n = 29, k = 5 (M = 118,755), prompting stochastic subsampling (Wilde and Grimshaw, 2013). We show that this barrier is computational, not combinatorial: storing all subsets requires Θ(kM) space, whereas stateful enumeration uses O(k) auxiliary state and retains only M kernel values. We combine two exhaustive traversals with three-way Quickselect and a deterministic median-of-medians fallback, giving worst-case O(M) selection. Gosper's successor takes O(k) kernel work per subset for n < w; a Revolving Door Gray code changes one element out and one in, enabling O(1) kernel updates between recalibrations and O(M + kM/P) total time. We derive floating-point error bounds for the location (h1) and mean-centered sample variance (h2) kernels and their resulting median. For n = 29, k = 5, our ANSI C implementation evaluates all 118,755 subsets in 0.74 ms and 0.71 ms, respectively. A direct C sweep places the crossover with partial lexicographic unranking at approximately 18,000-23,000 subsets (15\%-19\% of M), below the 32,160-45,420 subsets required by Wilde and Grimshaw's sequential approximation at ε= 0.01.
Create a lesson
Related papers
Shellsort with O(n n) Average-Case Complexity
Cheng Du, Zongqi Wan
Space-Efficient Text Indexing for Advanced Counting Queries
Solon P. Pissis, Sharma V. Thankachan
Tight Logarithmic Separations between LZ77 and LZRR
Yuto Fujie
Balanced Divide and Conquer for Rooted Maximum Agreement Forests
Feng Shi, Yexin Peng, Xin Zeng et al.
Distribution-Robust Halfspace Testing
Xi Chen, Renato Ferreira Pinto, Nathaniel Harms et al.
Testable Testing: Distribution-Robust Property Testing
Xi Chen, Renato Ferreira Pinto, Nathaniel Harms et al.