def _relative_shoots_select(ensembles, rgen, relative):
    """Randomly select the ensemble for 'relative' shooting moves.

    Here we select the ensemble to do the shooting in based on relative
    probabilities. We draw a random number in [0, 1] which is used to
    select the ensemble.

    Parameters
    ----------
    ensembles : list of objects like `PathEnsemble` from `.path`.
        This is a list of the ensembles we are using in the RETIS method
    rgen : object like `RandomGenerator` from `.random_gen`.
        This is a random generator. Here we assume that we can call
        `rgen.rand()` to draw random uniform numbers.
    relative : list of floats
        These are the relative probabilities for the ensembles. We
        assume here that these numbers are normalized.

    Returns
    -------
    out[0] : integer
        The index of the path ensemble to shoot in.
    out[1] : object like `PathEnsemble` from `.path`.
        The selected path ensemble for shooting.
    """
    freq = rgen.rand()
    cumulative = 0.0
    idx = None
    for idx, path_freq in enumerate(relative):
        cumulative += path_freq
        if freq < cumulative:
            break
    try:
        path_ensemble = ensembles[idx]
    except TypeError:
        msg = 'Error in relative shoot frequencies! Aborting!'
        raise ValueError(msg)
    return idx, path_ensemble
