def linear_annealing(n, total, p_initial, p_final):
    """Linear annealing between p_initial and p_final
    over total steps - computes value at step n"""
    if n >= total:
        return p_final
    else:
        return p_initial - (n * (p_initial - p_final)) / (total)