\begin{algorithm}[!htb]
\caption{Iterative Grouped Histogram Binning (IGHB)}
\label{alg:ighb}
\begin{algorithmic}[1]
\STATE \textbf{Input:} scoring function $f'$, max iterations $T$
\STATE Let $H_t(p, g) = P_D ( S_{p,g}(f_t) ) \Delta^2_{p,g}(f_t)$
\STATE Initialize $f_0 = f'$
\FOR{$t \in \{0, 1, \ldots, T-1 \}$}
    \STATE Set
    \[
        (p_t, g_t) = \argmax_{p \in \left[ \frac{1}{m} \right], g \in \mathcal{G}} H_t(p, g)
    \]
    \STATE Let $\Delta_t = \Delta_{p_t, g_t}$ and $S_t = S_{p_t, g_t}$
    \STATE Set 
    \[
        h_{t+1}(x) = 
        \begin{cases} 
        f_t(x) + \Delta_t(f_t) & \text{if } x \in S_t(f_t) \\
        f_t(x) & \text{otherwise}
        \end{cases}
    \]
    \STATE Set $f_{t+1} = h_{t+1}$
    \IF{$H_t(p_t, g_t) \ge H_{t-1}(p_{t-1}, g_{t-1})$} 
        \STATE Set t = t-1
        \BREAK
    \ENDIF
\ENDFOR
\STATE \textbf{Output:} $H_t$
\end{algorithmic}
\end{algorithm}