import random


def choose_from_hist( hist ):
    """Return a random value from the histogram
    chosen with probability in proportion to frequency.
    """
    t = []
    for word, freq in hist.iteritems():
        t.extend( [word] * freq )

    return random.choice( t )