def compute_convergence(output, output_prev):
    """
    Compute the convergence by comparing with the output from the previous
    iteration.

    The convergence is measured as the mean of a XOR operation on two vectors.

    Parameters
    ----------
    output, output_prev : np.ndarray
        Current and previous iteration binary outputs.

    Returns
    -------
    float
        The model convergence between 0 (fully converged) and 1 (fully chaotic)
    """
    if output is None or output_prev is None:
        return None
    return (output ^ output_prev).mean()