def sample(self, rgen):
rf = rgen.uniform(<NUM_LIT:0>, self.sum)<EOL>index = bisect.bisect(self.cdf, rf)<EOL>return self.keys[index], numpy.log(self.pmf[index])<EOL>
Generates a random sample from the discrete probability distribution
        and returns its value and the log of the probability of sampling that value.