Esempio 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))
Esempio 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))
Esempio 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))
Esempio 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)
        )
Esempio 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
Esempio 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
Esempio 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))
Esempio 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)
            )
Esempio 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
Esempio n. 10
0
 def produce_template(self, context, p):
     return dist.biased_coin(context.random, p)
Esempio n. 11
0
 def produce_parameter(self, random):
     return self.Parameter(
         cut=random.random(),
         leftwards=dist.biased_coin(random, 0.5)
     )
Esempio 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),
     )
Esempio 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
Esempio 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)
Esempio 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
Esempio n. 17
0
 def draw_parameter(self, random):
     return self.Parameter(
         cut=random.random(),
         leftwards=dist.biased_coin(random, 0.5)
     )
Esempio 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),
     )
Esempio n. 19
0
 def draw_template(self, random, p):
     return dist.biased_coin(random, p)