示例#1
0
    def query_model(self):
        if flip(0.9):
            self.a = uniform(0, 1)
        else:
            self.a = 0.7

        self.b = flip(self.a)
示例#2
0
    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)
示例#3
0
    def query_model(self):
        if flip(0.9):
            self.a = beta(1, 5)
        else:
            self.a = 0.7

        self.b = flip(self.a)
示例#4
0
    def query_model(self):
        if flip(0.9):
            self.a = uniform(0, 1)
        else:
            self.a = 0.7

        self.b = flip(self.a)
示例#5
0
文件: test2.py 项目: jhamrick/pystoch
    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)
示例#6
0
    def query_model(self):
        if flip(0.9):
            self.a = beta(1, 5)
        else:
            self.a = 0.7

        self.b = flip(self.a)
示例#7
0
    def query_model(self):
        if flip(0.7):
            self.proc = self.proc1
        else:
            self.proc = self.proc2

        self.samp = self.proc(1)
示例#8
0
    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)
示例#9
0
    def query_model(self):
        if flip(0.7):
            self.proc = self.proc1
        else:
            self.proc = self.proc2

        self.samp = self.proc(1)
示例#10
0
    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)
示例#11
0
文件: test5.py 项目: jhamrick/pystoch
    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()
示例#12
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()
示例#13
0
文件: test3.py 项目: jhamrick/pystoch
    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))
示例#14
0
 def query_model(self):
     self.hyp = flip(0.7)
示例#15
0
 def proc2(self, x):
     return flip(0.8)
示例#16
0
 def query_model(self):
     if flip(0.7):
         weight = 0.2
     else:
         weight = 0.8
     self.val = flip(weight)
示例#17
0
import pystoch
from pystoch import flip

result = []
for sample in xrange(SAMPLES):
    result.append(int(flip(0.7)))
exresult = 0.7
示例#18
0
 def bit_flip(self, fidelity, x):
     if x:
         return flip(fidelity)
     else:
         return flip(1 - fidelity)
示例#19
0
 def sample(self):
     if flip(0.7):
         weight = 0.2
     else:
         weight = 0.8
     return flip(weight)
示例#20
0
 def query_model(self):
     self.a = flip(0.7)
示例#21
0
文件: flip.py 项目: jhamrick/pystoch
 def query_model(self):
     self.val = flip()
示例#22
0
文件: test4.py 项目: jhamrick/pystoch
 def coin(self, weight):
     if flip(weight):
         return 'H'
     return 'T'
示例#23
0
 def query_model(self):
     self.hyp = flip(0.7)
     self.cond = self.bit_flip(0.8, self.hyp)
示例#24
0
 def sample(self):
     return int(flip(0.7))
示例#25
0
文件: test3.py 项目: jhamrick/pystoch
    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))
        )
示例#26
0
 def query_model(self):
     if flip(0.7):
         weight = 0.2
     else:
         weight = 0.8
     self.val = flip(weight)
示例#27
0
 def proc1(self, x):
     return flip(0.2)
示例#28
0
文件: test1.py 项目: jhamrick/pystoch
 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
示例#29
0
 def query_model(self):
     self.a = flip(0.7)
示例#30
0
 def sample(self):
     return int(flip(0.7))
示例#31
0
文件: test4.py 项目: jhamrick/pystoch
 def coin(self, weight):
     if flip(weight):
         return 'H'
     return 'T'
示例#32
0
 def condition(self):
     return flip(self.a)
示例#33
0
 def power_law(self, prob, x):
     if flip(prob):
         return x
     else:
         return self.power_law(prob, x + 1)
示例#34
0
 def query_model(self):
     self.val = flip()
示例#35
0
 def query_model(self):
     if flip(0.7):
         self.val = flip(0.2)
     else:
         self.val = flip(0.8)
示例#36
0
 def proc2(self, x):
     return flip(0.8)
示例#37
0
 def query_model(self):
     self.a = flip()
     self.b = flip()
示例#38
0
 def proc1(self, x):
     return flip(0.2)
示例#39
0
 def bit_flip(self, fidelity, x):
     if x:
         return flip(fidelity)
     else:
         return flip(1 - fidelity)
示例#40
0
 def query_model(self):
     self.hyp = flip(0.7)
示例#41
0
 def sample(self):
     if flip(0.7):
         return flip(0.2)
     else:
         return flip(0.8)
示例#42
0
 def query_model(self):
     self.val = int(flip(0.7))
示例#43
0
 def query_model(self):
     self.a = flip()
     self.b = flip()
示例#44
0
 def condition(self):
     return flip(self.a)
示例#45
0
 def power_law(self, prob, x):
     if flip(prob):
         return x
     else:
         return self.power_law(prob, x + 1)
示例#46
0
 def query_model(self):
     if flip(0.7):
         self.val = flip(0.2)
     else:
         self.val = flip(0.8)
示例#47
0
 def sample(self):
     if flip(0.7):
         return flip(0.2)
     else:
         return flip(0.8)
示例#48
0
 def sample(self):
     if flip(0.7):
         weight = 0.2
     else:
         weight = 0.8
     return flip(weight)