Пример #1
0
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)
Пример #2
0
def add(a, b):
    #print(a, b)
    return BoundedDiscreteDistribution({a + b: 1})
Пример #3
0
def div(a, b):
    return BoundedDiscreteDistribution({a / float(b): 1})
Пример #4
0
def dis_from_num(num):
    return BoundedDiscreteDistribution({num: 1})
Пример #5
0
def mul(a, b):
    return BoundedDiscreteDistribution({a * b: 1})
Пример #6
0
def mx(a, b):
    return BoundedDiscreteDistribution({max(a, b): 1})
Пример #7
0
def gt(a, b):
    if a > b:
        return BoundedDiscreteDistribution({1: 1})
    return BoundedDiscreteDistribution({0: 1})
Пример #8
0
def sub(a, b):
    return BoundedDiscreteDistribution({a - b: 1})
Пример #9
0
 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)