def query_model(self): if flip(0.9): self.a = uniform(0, 1) else: self.a = 0.7 self.b = flip(self.a)
def query_model(self): self.breast_cancer = flip(0.01) if self.breast_cancer: self.positive_mammogram = flip(0.8) else: self.positive_mammogram = flip(0.096)
def query_model(self): if flip(0.9): self.a = beta(1, 5) else: self.a = 0.7 self.b = flip(self.a)
def query_model(self): if flip(0.7): self.proc = self.proc1 else: self.proc = self.proc2 self.samp = self.proc(1)
def query_model(self): if flip(0.9): self.a = exponential(2.0) else: self.a = 0.7 self.b = gaussian(self.a, 1.0)
def query_model(self): if flip(): self.hypothesis = BIG else: self.hypothesis = SMALL self.observations = [uniform_draw(self.hypothesis_set(self.hypothesis)) for i in xrange(len(self.data))] self.observations.sort()
def query_model(self): if flip(): self.hypothesis = BIG else: self.hypothesis = SMALL self.observations = [ uniform_draw(self.hypothesis_set(self.hypothesis)) for i in xrange(len(self.data)) ] self.observations.sort()
def query_model(self): self.lung_cancer = flip(0.01) self.TB = flip(0.005) self.cold = flip(0.2) self.stomach_flu = flip(0.1) self.other = flip(0.1) self.cough = (self.cold and flip(0.5)) or \ (self.lung_cancer and flip(0.3)) or \ (self.TB and flip(0.7)) or \ (self.other and flip(0.01)) self.fever = (self.cold and flip(0.3)) or \ (self.stomach_flu and flip(0.5)) or \ (self.TB and flip(0.2)) or \ (self.other and flip(0.01)) self.chest_pain = (self.lung_cancer and flip(0.4)) or \ (self.TB and flip(0.5)) or \ (self.other and flip(0.01)) self.shortness_of_breath = (self.lung_cancer and flip(0.4)) or \ (self.TB and flip(0.5)) or \ (self.other and flip(0.01))
def query_model(self): self.hyp = flip(0.7)
def proc2(self, x): return flip(0.8)
def query_model(self): if flip(0.7): weight = 0.2 else: weight = 0.8 self.val = flip(weight)
import pystoch from pystoch import flip result = [] for sample in xrange(SAMPLES): result.append(int(flip(0.7))) exresult = 0.7
def bit_flip(self, fidelity, x): if x: return flip(fidelity) else: return flip(1 - fidelity)
def sample(self): if flip(0.7): weight = 0.2 else: weight = 0.8 return flip(weight)
def query_model(self): self.a = flip(0.7)
def query_model(self): self.val = flip()
def coin(self, weight): if flip(weight): return 'H' return 'T'
def query_model(self): self.hyp = flip(0.7) self.cond = self.bit_flip(0.8, self.hyp)
def sample(self): return int(flip(0.7))
def query_model(self): self.lung_cancer = flip(0.01) self.TB = flip(0.005) self.cold = flip(0.2) self.stomach_flu = flip(0.1) self.other = flip(0.1) self.cough = ( (self.cold and flip(0.5)) or (self.lung_cancer and flip(0.3)) or (self.TB and flip(0.7)) or (self.other and flip(0.01)) ) self.fever = ( (self.cold and flip(0.3)) or (self.stomach_flu and flip(0.5)) or (self.TB and flip(0.2)) or (self.other and flip(0.01)) ) self.chest_pain = (self.lung_cancer and flip(0.4)) or (self.TB and flip(0.5)) or (self.other and flip(0.01)) self.shortness_of_breath = ( (self.lung_cancer and flip(0.4)) or (self.TB and flip(0.5)) or (self.other and flip(0.01)) )
def proc1(self, x): return flip(0.2)
def query_model(self): self.A = int(flip(self.baserate)) self.B = int(flip(self.baserate)) self.C = int(flip(self.baserate)) self.D = self.A + self.B + self.C
def condition(self): return flip(self.a)
def power_law(self, prob, x): if flip(prob): return x else: return self.power_law(prob, x + 1)
def query_model(self): if flip(0.7): self.val = flip(0.2) else: self.val = flip(0.8)
def query_model(self): self.a = flip() self.b = flip()
def sample(self): if flip(0.7): return flip(0.2) else: return flip(0.8)
def query_model(self): self.val = int(flip(0.7))