def cycle_prev(id,cycle_length):
    """
    computes the previous id in a cycle

    Parameters
    ----------
    id : integer
        The index of an item in the cycle.
    cycle_length : integer
        The length of the cycle.

    Returns
    -------
    integer
        The index of the previous item in the cycle
        """
    if id==0:
        return cycle_length-1
    else:
        return id-1