Exemplo n.º 1
0
    def draw_template(self, random, pv):
        sign = int(dist.biased_coin(random, pv.negative_probability))
        if dist.biased_coin(random, pv.subnormal_probability):
            exponent = 0
        else:
            exponent = random.getrandbits(11)

        return compose_float(sign, exponent, random.getrandbits(52))
Exemplo n.º 2
0
    def draw_template(self, random, pv):
        sign = int(dist.biased_coin(random, pv.negative_probability))
        if dist.biased_coin(random, pv.subnormal_probability):
            exponent = 0
        else:
            exponent = random.getrandbits(11)

        return compose_float(sign, exponent, random.getrandbits(52))
Exemplo n.º 3
0
    def produce_template(self, context, pv):
        sign = int(dist.biased_coin(context.random, pv.negative_probability))
        if dist.biased_coin(context.random, pv.subnormal_probability):
            exponent = 0
        else:
            exponent = context.random.getrandbits(11)

        return compose_float(sign, exponent, context.random.getrandbits(52))
Exemplo n.º 4
0
    def produce_template(self, context, pv):
        sign = int(dist.biased_coin(context.random, pv.negative_probability))
        if dist.biased_coin(context.random, pv.subnormal_probability):
            exponent = 0
        else:
            exponent = context.random.getrandbits(11)

        return compose_float(
            sign,
            exponent,
            context.random.getrandbits(52)
        )
Exemplo n.º 5
0
 def produce_template(self, context, pv):
     base = math.ldexp(
         context.random.random(),
         -context.random.randint(pv.min_exponent, self.max_exponent)
     )
     if dist.biased_coin(context.random, pv.negative_probability):
         base = -base
     return base
Exemplo n.º 6
0
 def produce_template(self, context, pv):
     base = math.ldexp(
         context.random.random(),
         -context.random.randint(pv.min_exponent, self.max_exponent)
     )
     if dist.biased_coin(context.random, pv.negative_probability):
         base = -base
     return base
Exemplo n.º 7
0
    def draw_template(self, random, pv):
        sign = int(dist.biased_coin(random, pv.negative_probability))
        if dist.biased_coin(random, pv.subnormal_probability):
            return compose_float(sign, 0, random.getrandbits(52))
        else:
            if self.allow_infinity and self.allow_nan:
                return compose_float(sign, random.getrandbits(11),
                                     random.getrandbits(52))
            if not self.allow_infinity and not self.allow_nan:
                exponent = random.getrandbits(11)
                while exponent == 2047:
                    exponent = random.getrandbits(11)
                return compose_float(sign, exponent, random.getrandbits(52))

            exponent = random.getrandbits(11)
            if exponent == 2047:
                return compose_float(sign, exponent,
                                     0 if self.allow_infinity else 1)
            return compose_float(sign, exponent, random.getrandbits(52))
Exemplo n.º 8
0
    def draw_template(self, random, pv):
        sign = int(dist.biased_coin(random, pv.negative_probability))
        if dist.biased_coin(random, pv.subnormal_probability):
            return compose_float(
                sign,
                0,
                random.getrandbits(52)
            )
        else:
            if self.allow_infinity and self.allow_nan:
                return compose_float(
                    sign,
                    random.getrandbits(11),
                    random.getrandbits(52)
                )
            if not self.allow_infinity and not self.allow_nan:
                exponent = random.getrandbits(11)
                while exponent == 2047:
                    exponent = random.getrandbits(11)
                return compose_float(
                    sign,
                    exponent,
                    random.getrandbits(52)
                )

            exponent = random.getrandbits(11)
            if exponent == 2047:
                return compose_float(
                    sign,
                    exponent,
                    0 if self.allow_infinity else 1
                )
            return compose_float(
                sign,
                exponent,
                random.getrandbits(52)
            )
Exemplo n.º 9
0
 def draw_template(self, random, parameter):
     value = dist.geometric(random, parameter.p)
     if dist.biased_coin(random, parameter.negative_probability):
         value = -value
     return value
Exemplo n.º 10
0
 def produce_template(self, context, p):
     return dist.biased_coin(context.random, p)
Exemplo n.º 11
0
 def produce_parameter(self, random):
     return self.Parameter(
         cut=random.random(),
         leftwards=dist.biased_coin(random, 0.5)
     )
Exemplo n.º 12
0
 def produce_parameter(self, random):
     return self.Parameter(
         lambd=random.gammavariate(2, 50),
         zero_point=random.normalvariate(0, 1),
         negative=dist.biased_coin(random, 0.5),
     )
Exemplo n.º 13
0
 def produce_template(self, context, parameter):
     value = dist.geometric(context.random, parameter.p)
     if dist.biased_coin(context.random, parameter.negative_probability):
         value = -value
     return value
Exemplo n.º 14
0
 def draw_template(self, random, parameter):
     value = dist.geometric(random, parameter.p)
     if dist.biased_coin(random, parameter.negative_probability):
         value = -value
     return value
 def draw_template(self, random, p):
     return dist.biased_coin(random, p)
Exemplo n.º 16
0
 def produce_template(self, context, parameter):
     value = dist.geometric(context.random, parameter.p)
     if dist.biased_coin(context.random, parameter.negative_probability):
         value = -value
     return value
Exemplo n.º 17
0
 def draw_parameter(self, random):
     return self.Parameter(
         cut=random.random(),
         leftwards=dist.biased_coin(random, 0.5)
     )
Exemplo n.º 18
0
 def draw_parameter(self, random):
     return self.Parameter(
         lambd=random.gammavariate(2, 50),
         zero_point=random.normalvariate(0, 1),
         negative=dist.biased_coin(random, 0.5),
     )
Exemplo n.º 19
0
 def draw_template(self, random, p):
     return dist.biased_coin(random, p)