def dice(n, d): #print(n, d) n_i = BoundedDiscreteDistribution({n: 1}).intize() d_i = BoundedDiscreteDistribution({d: 1}).intize() #print(str(n_i), str(d_i)) def op(a, b): #print(a, b) s = BoundedDiscreteDistribution({0: 1}) for i in range(a): s = s.apply_op(add, uniform_discdist(1, b)) return s.norm_weights_to(2**32) return n_i.apply_op(op, d_i)
def add(a, b): #print(a, b) return BoundedDiscreteDistribution({a + b: 1})
def div(a, b): return BoundedDiscreteDistribution({a / float(b): 1})
def dis_from_num(num): return BoundedDiscreteDistribution({num: 1})
def mul(a, b): return BoundedDiscreteDistribution({a * b: 1})
def mx(a, b): return BoundedDiscreteDistribution({max(a, b): 1})
def gt(a, b): if a > b: return BoundedDiscreteDistribution({1: 1}) return BoundedDiscreteDistribution({0: 1})
def sub(a, b): return BoundedDiscreteDistribution({a - b: 1})
def op(a, b): #print(a, b) s = BoundedDiscreteDistribution({0: 1}) for i in range(a): s = s.apply_op(add, uniform_discdist(1, b)) return s.norm_weights_to(2**32)