def dynamical_tolerance(tolerance_range, gaussbock_iterations, step):
    """Calculate the model's convergence threshold dynamically for the given iteration.

    The variational Bayesian non-parametric Gaussian mixture model used in this code
    requires a convergence threshold to terminate before reaching the maximum number
    of model-fitting iterations. As the initial sample isn't a great fit for the true
    posterior distribution, optimizing the fit to a very strict convergence threshold
    isn't very sensible. Instead, the convergence threshold decreases linearly with
    each full iteration, with the change from iteration to iteration being dependent
    on the range that is provided by the user to allow customization to a problem.

    Parameters:
    -----------
    tolerance_range : list
        The two ends for the shrinking convergence threshold as a tuple [float, float].

    gaussbock_iterations : int
        The number of iterations that gaussbock should circle through to achieve a fit.

    step : int
        the index of the current iteration, i.e. a counter to keep track of progress.

    Returns:
    --------
    step_tolerance : float
        A desired convergence threshold for the given step's model-fitting process.

    Attributes:
    -----------
    None
    """
    difference = tolerance_range[0] - tolerance_range[1]
    increase = difference / (gaussbock_iterations - 1)
    step_tolerance = tolerance_range[0] - step * increase
    return step_tolerance
