Skip to content

Instantly share code, notes, and snippets.

@miku
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miku/9253697 to your computer and use it in GitHub Desktop.
Save miku/9253697 to your computer and use it in GitHub Desktop.
Bayes et al.

Story

A conditional probability is a probability based on some background information - that make up a condition.

The cookie problem

Suppose there are two bowls of cookies. Bowl 1 contains 30 vanilla cookies and 10 chocolate cookies. Bowl 2 contains 20 of each. Now suppose you choose one of the bowls at random and, without looking, select a cookie at random. The cookie is vanilla. What is the probability that it came from Bowl 1?

The diachronic interpretation

p(H|D) = P(H) * (D|H) / P(D)

  • p(H): prior
  • p(H|D): posterior
  • p(D|H): likelihood, probability of the data under the hypothesis
  • p(D): normalizing constant

The normalizing constant can be tricky. It is supposed to be the probability of seeing the data under any hypothesis at all, but in the most general case it is hard to nail down what that means.

#!/usr/bin/env python
"""
Example code.
"""
if __name__ == '__main__':
print("Hello World")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment