def walk(chains, start, end, step):
    """ Calculates Gelman-Rubin conervergence statistic along chains of data.
    This function will advance along the chains and calculate the
    statistic for each step.

    Parameters
    ----------
    chains : iterable
        An iterable of numpy.array instances that contain the samples
        for each chain. Each chain has shape (nparameters, niterations).
    start : float
        Start index of blocks to calculate all statistics.
    end : float
        Last index of blocks to calculate statistics.
    step : float
        Step size to take for next block.

    Returns
    -------
    starts : numpy.array
        1-D array of start indexes of calculations.
    ends : numpy.array
        1-D array of end indexes of caluclations.
    stats : numpy.array
        Array with convergence statistic. It has
        shape (nparameters, ncalculations).
    """

    # get number of chains, parameters, and iterations
    chains = numpy.array(chains)
    _, nparameters, _ = chains.shape

    # get end index of blocks
    ends = numpy.arange(start, end, step)
    stats = numpy.zeros((nparameters, len(ends)))

    # get start index of blocks
    starts = numpy.array(len(ends) * [start])

    # loop over end indexes and calculate statistic
    for i, e in enumerate(ends):
        tmp = chains[:, :, 0:e]
        stats[:, i] = gelman_rubin(tmp)

    return starts, ends, stats