AllenDowney / ThinkBayes2

Text and code for the forthcoming second edition of Think Bayes, by Allen Downey.
http://allendowney.github.io/ThinkBayes2/
MIT License
1.8k stars 1.49k forks source link

Chapter 2 Bayes' Theorem #42

Open ckchmod opened 3 years ago

ckchmod commented 3 years ago

I believe the function update() should return the table, not "prob_data".

def update(table): """Compute the posterior probabilities.""" table['unnorm'] = table['prior'] * table['likelihood'] prob_data = table['unnorm'].sum() table['posterior'] = table['unnorm'] / prob_data return prob_data

AllenDowney commented 3 years ago

That interface is as intended: the function modifies the table, so it's not necessary to return it.

And for some purposes it is useful to see the total probability of the data.

On Thu, May 27, 2021, at 3:52 PM, CK wrote:

I believe the function update() should return the table, not "prob_data".

def update(table): """Compute the posterior probabilities.""" table['unnorm'] = table['prior'] * table['likelihood'] prob_data = table['unnorm'].sum() table['posterior'] = table['unnorm'] / prob_data return prob_data

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AllenDowney/ThinkBayes2/issues/42, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOLP3PED4RGKY3BLVBKUL3TP2PGFANCNFSM45U7I3PQ.