def normalize(self):
"""
Returns a new distribution with the probabilities normalized so that
their total sums to 1.
"""
if math.isclose(self.total, 1) or self.total == 0:
return self
return Distribution(*((v, p/self.total) for v, p in self), force_flatten=self.force_flatten, force_merge=self.force_merge)
评论列表
文章目录