The median trick is a generic approach that increases the chances of a probabilistic algorithm to succeed. Apparently first used in 1986 by Jerrum et al. for approximate counting algorithms, the technique was later applied to a broad selection of classification and regression problems. The idea of median trick is very simple: run the randomized algorithm with numeric output multiple times, and use the median of the obtained results as a final answer. For example, if an algorithm takes a set of data as input, and has sublinear runtime, then the same algorithm can be run repeatedly (or in parallel) over randomly sampled subsets of input data, and, per Chernoff inequality, the median of the results will converge to solution rapidly. Similarly, for the algorithms that are sublinear in space (e.g., counting the distinct elements of a stream), different randomizations of the algorithm (say, with different hash functions) may be used for repeated runs over the same data.
Statement Given a set of independent random variables X 1 , … , X n {\textstyle X_{1},\dots ,X_{n}} , and an unknown deterministic number Y {\textstyle Y} . Suppose that each random variable X i {\textstyle X_{i}} falls within [ Y ± ϵ ] {\textstyle [Y\pm \epsilon ]} with probability ≥ p {\textstyle \geq p} where p > 1 / 2 {\textstyle p>1/2} is a constant, then the median trick states that M e d ( X i ) ∈ [ Y ± ϵ ] {\textstyle Med(X_{i})\in [Y\pm \epsilon ]} with probability ≥ 1 − e − 2 n ( p − 1 / 2 ) 2 {\textstyle \geq 1-e^{-2n(p-1/2)^{2}}} . In other words, in order to ensure that Y ∈ [ M e d ( X i ) ± ϵ ] {\textstyle Y\in [Med(X_{i})\pm \epsilon ]} with probability ≥ 1 − δ {\textstyle \geq 1-\delta } , it suffices to use ln 1 δ 2 ( p − 1 / 2 ) 2 {\textstyle {\frac {\ln {\frac {1}{\delta }}}{2(p-1/2)^{2}}}} samples.
References
Sources Kogler, Alexander; Traxler, Patrick (2017). "Parallel and Robust Empirical Risk Minimization via the Median Trick". Mathematical Aspects of Computer and Information Sciences. Cham: Springer International Publishing. doi:10.1007/978-3-319-72453-9_31. ISBN 978-3-319-72452-2. ISSN 0302-9743. Jerrum, Mark R.; Valiant, Leslie G.; Vazirani, Vijay V. (1986). "Random generation of combinatorial structures from a uniform distribution". Theoretical Computer Science. 43. Elsevier BV: 169–188. doi:10.1016/0304-3975(86)90174-x. ISSN 0304-3975. Wang, Dan; Han, Zhu (2015). "Basics for Sublinear Algorithms". Sublinear Algorithms for Big Data Applications. Cham: Springer International Publishing. doi:10.1007/978-3-319-20448-2_2. ISBN 978-3-319-20447-5. ISSN 2191-5768.
