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