def adapt_factor_func(b, n_batch):
    """ Calculates adaption factor to use during an adaptive MH run.

    Based on adaption schedule used in code accompanying paper:

    `Pseudo-Marginal Bayesian Inference for Gaussian Processes`,
    Filippone and Girolami (2013)

    Parameters
    ----------
    b : integer
         Index of current batch of updates (each batch of updates being
         used to calculate an average accept rate).
    n_batch : integer
         Total number batches to be used in full adaptive run.

    Returns
    -------
    adapt_factor : double
         Factor to use to scale changes in adapation of proposal parameters.
    """
    return 5. - min(b + 1, n_batch / 5.) / (n_batch / 5.) * 3.9