def __init__(self, data={}): """Create a unit mass function""" if isinstance(data, Mapping): # Hashable Mapping to Rational umfunc = Vector(data).sum_normalized() if umfunc == None: raise ValueError("no UMFunc can be constructed from a Mapping " + str(data) + " with a total mass of zero") Vector.__init__(self, umfunc | umfunc.support()) else: # uniform over Hashable Container Vector.__init__(self, {component: Fraction(1, len(data)) for component in data})
def __init__(self, data={}): """Create a gamble""" if isinstance(data, Mapping): # Hashable Mapping to Rational Vector.__init__(self, data) else: # indicator over Hashable Container Vector.__init__(self, {component: 1 for component in data})