def Normalize(self, fraction=<NUM_LIT:1.0>):
if self.log:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>total = self.Total()<EOL>if total == <NUM_LIT:0.0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL>logging.warning('<STR_LIT>')<EOL>return total<EOL><DEDENT>factor = float(fraction) / total<EOL>for x in self.d:<EOL><INDENT>self.d[x] *= factor<EOL><DEDENT>return total<EOL>
Normalizes this PMF so the sum of all probs is fraction.

        Args:
            fraction: what the total should be after normalization

        Returns: the total probability before normalizing