def MakeCdfFromItems(items, name='<STR_LIT>'):
runsum = <NUM_LIT:0><EOL>xs = []<EOL>cs = []<EOL>for value, count in sorted(items):<EOL><INDENT>runsum += count<EOL>xs.append(value)<EOL>cs.append(runsum)<EOL><DEDENT>total = float(runsum)<EOL>ps = [c / total for c in cs]<EOL>cdf = Cdf(xs, ps, name)<EOL>return cdf<EOL>
Makes a cdf from an unsorted sequence of (value, frequency) pairs.

    Args:
        items: unsorted sequence of (value, frequency) pairs
        name: string name for this CDF

    Returns:
        cdf: list of (value, fraction) pairs