def Random(self):
if len(self.d) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>target = random.random()<EOL>total = <NUM_LIT:0.0><EOL>for x, p in self.d.iteritems():<EOL><INDENT>total += p<EOL>if total >= target:<EOL><INDENT>return x<EOL><DEDENT><DEDENT>assert False<EOL>
Chooses a random element from this PMF.

        Returns:
            float value from the Pmf