Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with the Euro examples... #7

Open
kabua opened this issue Oct 28, 2017 · 0 comments
Open

Errors with the Euro examples... #7

kabua opened this issue Oct 28, 2017 · 0 comments

Comments

@kabua
Copy link

kabua commented Oct 28, 2017

All the examples so far have worked as expected until chapter 4. In the example Euro.py I'm getting the following error message:

ValueError: Normalize: total probability is zero.

The error is generated because 'H' * heads => 0)0.0, ..., 99) 0.0, 100) 7.504617540403191e-09
and then when I try to process 'T' * tails => the suite is all zeros. Thus, the total is zero.

I was able to fix this issue by change this code

dataset = 'H' * 140 + 'T' * 110

to

dataset = 'H' * 140 + 'T' * 110
dataset = ''.join(random.sample(dataset, len(dataset)))

but I didn't get the same summary values as you did.

I'm all so seeing this same error in with Euro2.py

Environment:
I haveAnaconda 5.0 and VS2017 v15.4.1 installed. I'm running the examples from within VS, but VS is running the code from within Anaconda 5.0.0 (global Default)

Also, I'm getting the same error when I run it inside of the jupyter notebook

dataset = 'H' * 140 + 'T' * 110
suite = Euro(range(0, 101))
dataset = 'H' * 140 + 'T' * 110
​
for data in dataset:
    suite.Update(data)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-a0973cb6b830> in <module>()
      3 
      4 for data in dataset:
----> 5     suite.Update(data)

C:\Dev\Repos\ThinkBayes2\code\thinkbayes2.py in Update(self, data)
   1410             like = self.Likelihood(data, hypo)
   1411             self.Mult(hypo, like)
-> 1412         return self.Normalize()
   1413 
   1414     def LogUpdate(self, data):

C:\Dev\Repos\ThinkBayes2\code\thinkbayes2.py in Normalize(self, fraction)
    532         total = self.Total()
    533         if total == 0:
--> 534             raise ValueError('Normalize: total probability is zero.')
    535 
    536         factor = fraction / total

ValueError: Normalize: total probability is zero.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant