def stationarity(sequence):
    """
    Compute the stationarity of a sequence.

    A stationary transition is one whose source and destination symbols
    are the same. The stationarity measures the percentage of transitions
    to the same location.

    Parameters
    ----------
    sequence : list
        A list of symbols.

    Returns
    -------
    float
        Percentage of the sequence that is stationary.
    """
    n = len(sequence)
    n_unique = len(set(sequence))

    if n <= 1:
        return 1.0

    if n == n_unique:
        return .0

    stationary_transitions = 0
    for i in range(1, n):
        if sequence[i - 1] == sequence[i]:
            stationary_transitions += 1

    return stationary_transitions / (n - 1)