Suppose that we have an algorithm AA that estimates the mean E[Y]E[Y] of a random variable YY within some specified range rr with probability ρ>12\rho > \frac{1}{2}. We can derive a new algorithm A∗A^* from AA that boosts the successful probability to 1−δ1 - \delta, as follows:

  1. Repeat AA for m=12(ρ−0.5)2ln⁡1δm = \frac{1}{2 (\rho - 0.5)^2 } \ln \frac{1}{\delta} times.
  2. Take the median of the mm outputs.

To prove it, define the indicator random variable

Xi={1, if the i-th output of A is within the range r0,otherwise X_i = \begin{cases} 1, \text{ if the } i \text{-th output of } A \text{ is within the range } r \\ 0, \text{otherwise} \end{cases}

for 1≤i≤m1 \le i \le m. Then E[Xi]=ρ>0.5E[X_i] = \rho > 0.5. Let μ=E[∑i=1mXi]=mρ\mu = E \left[\sum_{i = 1}^m X_i \right] = m\rho.

By Hoeffding's inequality, for λ>0\lambda > 0 ,

Pr⁡[∣∑i=1mXi−μ∣≥λ]≤exp⁡(−2λ2m) \Pr \left[ \left| \sum_{i = 1}^m X_i - \mu \right| \ge \lambda \right] \le \exp \left(- \frac{2\lambda^2}{m} \right)

Replacing λ\lambda with μ−0.5m\mu - 0.5m, and mm with m=12(ρ−0.5)2ln⁡1δm = \frac{1}{2 (\rho - 0.5)^2 }\ln \frac{1}{\delta}, we get

Pr⁡[∑i=1mXi≤0.5m]≤Pr⁡[∣∑i=1mXi−μ∣≥m(ρ−0.5)]≤exp⁡(−2m(ρ−0.5)2)=δ \begin{aligned} \Pr \left[ \sum_{i = 1}^m X_i \le 0.5m \right] &\le \Pr \left[ \left| \sum_{i = 1}^m X_i - \mu \right| \ge m(\rho - 0.5) \right] \\ &\le \exp \left(- 2m(\rho - 0.5)^2 \right) \\ &= \delta \end{aligned}

Note that if more than half of AA outputs are correct, then the output of A∗A^* is correct. This happens with probability at least 1−δ1 - \delta.