Skip to content

Instantly share code, notes, and snippets.

@jcbozonier
Forked from anonymous/py.py
Created January 30, 2017 13:39
Show Gist options
  • Save jcbozonier/7fd2045a6c3677a57f4718de7ee68080 to your computer and use it in GitHub Desktop.
Save jcbozonier/7fd2045a6c3677a57f4718de7ee68080 to your computer and use it in GitHub Desktop.
Evaluating Walnut and Almond Mix
# The walnut/almond mix ratios we have hypothesized
hypotheses = [[.8, .2],
[.5,.5],
[.2,.8]]
# Evaluate the pdf for each hypothesis
# Note that we only evaluate the hypothesis
# for one nut. If it's 80% we know the
# other must be 20%.
pdf_score = np.array([ss.beta.pdf(hypothesis[0], 1+1, 1+5) for hypothesis in hypotheses])
# Normalize the pdf values to get probabilities
probabilities = pdf_score/pdf_score.sum()
# Pair up our hypotheses and associated probabilities
# and print them as a list for easy viewing.
print(list(zip(hypotheses, probabilities)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment