Example #1
0
        'Bowl 2': dict(vanilla=0.5, chocolate=0.5)
    }

    def Likelihood(self, data, hypo):
        mix = self.mixes[hypo]
        like = mix[data]
        return like


hypos = ['Bowl 1', 'Bowl 2']
pmf = Cookie(hypos)
# Cookie provides an Update method that takes data as a parameter and updates the probabilities:
# Update loops through each hypothesis in the suite and muiltiplies its probability by the likelihood
# of the data under the hypothesis.

pmf.Update('vanilla')

for hypo, prob in pmf.Items():
    print(hypo, prob)

print('\n')

dataset = ['vanilla', 'chocolate', 'vanilla']
for data in dataset:
    pmf.Update(data)

# The lines below will show different probabilities.

for data, prob in pmf.Items():
    print(data, prob)