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