def _sample_discrete__python(pmf, rand):
    """Returns a sample from a discrete distribution.

    Note: This version has no bells or whistles.

    Parameters
    ----------
    pmf : list of floats
        A list of floats representing the probability mass function. The events
        will be the indices of the list. The floats should represent
        probabilities (and not log probabilities).
    rand : float
        The sample is drawn using the passed number.

    Returns
    -------
    s : int
        The index of the sampled event.

    """
    total = 0
    for i, prob in enumerate(pmf):
        total += prob
        if rand < total:
            return i