Esempio n. 1
0
    def produce(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 produce(self, random, pv):
     if dist.biased_coin(random, pv.ascii_chance):
         return random.choice(self.ascii_characters)
     else:
         while True:
             result = hunichr(random.randint(0, sys.maxunicode))
             if unicodedata.category(result) != 'Cs':
                 return result
Esempio n. 3
0
 def draw(self, random):
     if len(self.elements) == 1:
         return [self.elements[0]]
     result = []
     while not result:
         result = [
             x
             for x in self.elements
             if dist.biased_coin(random, self.activation_chance)
         ]
     return result
Esempio n. 4
0
 def draw(self, random):
     return dist.biased_coin(random, self.probability)
Esempio n. 5
0
 def produce(self, random, p):
     return dist.biased_coin(random, p)
Esempio n. 6
0
 def produce(self, random, parameter):
     value = dist.geometric(random, parameter.p)
     if dist.biased_coin(random, parameter.negative_probability):
         value = -value
     return value
Esempio n. 7
0
 def produce(self, random, pv):
     if dist.biased_coin(random, pv.example_probability):
         return random.choice(pv.examples)
     else:
         return self.main_strategy.produce(random, pv.main)