In [46]:
import scipy.stats as ss
import numpy as np

In [197]:
hypotheses = [[.8, .2], [.5,.5], [.2,.8]]
pdf_score = np.array([ss.beta.pdf(hypothesis[0], 1+1,1+5) for hypothesis in hypotheses])
probabilities = pdf_score/pdf_score.sum()

list(zip(hypotheses, probabilities))

In [199]:
hypotheses = [[.8, .2], [.5,.5], [.2,.8]]
pdf_score = np.array([ss.beta.pdf(hypothesis[0], 1+1+2,1+5+3) for hypothesis in hypotheses])
probabilities = pdf_score/pdf_score.sum()

list(zip(hypotheses, probabilities))


Out[199]:
[([0.8, 0.2], 0.00071554864238494969),
 ([0.5, 0.5], 0.26656264155542536),
 ([0.2, 0.8], 0.73272180980218971)]

In [123]:
pdf_array = np.array([ss.beta.pdf(0.8, 2, 6), ss.beta.pdf(0.5, 2, 6), ss.beta.pdf(0.2, 2, 6)])
pdf_array/pdf_array.sum()


Out[123]:
array([ 0.00314431,  0.19191324,  0.80494246])

In [51]:


In [202]:
hypotheses = [[.8, .2], 
              [.5,.5], 
              [.2,.8]]
# Notice how we swapped out the Beta for
# a Dirichlet. The only difference is we
# now pass a list of counts to the pdf
# function. We'll get to why in a bit.
pdf_score = np.array([ss.dirichlet.pdf(hypothesis, [1+1+2,1+5+3]) for hypothesis in hypotheses])
probabilities = pdf_score/pdf_score.sum()

print(list(zip(hypotheses, probabilities)))


[([0.8, 0.2], 0.00071554864238495164), ([0.5, 0.5], 0.26656264155542514), ([0.2, 0.8], 0.73272180980218982)]

In [191]:
hypotheses = [[1/3,1/3,1/3], [.8, .1, .1], [.1,.8,.1],[.1,.1,.8]]
pdf_score = np.array([ss.dirichlet.pdf(hypothesis, [1+1, 1+5, 1+2]) for hypothesis in hypotheses])
probabilities = pdf_score/pdf_score.sum()

In [192]:
list(zip(hypotheses, probabilities))


Out[192]:
[([0.3333333333333333, 0.3333333333333333, 0.3333333333333333],
  0.31699414486454858),
 ([0.8, 0.1, 0.1], 0.00016638388675650501),
 ([0.1, 0.8, 0.1], 0.68150840015464287),
 ([0.1, 0.1, 0.8], 0.0013310710940520379)]

In [203]:
hypotheses = [[1/3,1/3,1/3], [.8, .1, .1], [.1,.8,.1],[.1,.1,.8]]
pdf_score = np.array([ss.dirichlet.pdf(hypothesis, [1+1, 1+5, 1+2]) for hypothesis in hypotheses])
probabilities = pdf_score/pdf_score.sum()
list(zip(hypotheses, probabilities))


Out[203]:
[([0.3333333333333333, 0.3333333333333333, 0.3333333333333333],
  0.31699414486454858),
 ([0.8, 0.1, 0.1], 0.00016638388675650501),
 ([0.1, 0.8, 0.1], 0.68150840015464287),
 ([0.1, 0.1, 0.8], 0.0013310710940520379)]

In [204]:
hypotheses = [[1/3,1/3,1/3], [.8, .1, .1], [.1,.8,.1],[.1,.1,.8]]
pdf_score = np.array([ss.dirichlet.pdf(hypothesis, [1+1+1, 1+5+4, 1+2+4]) for hypothesis in hypotheses])
probabilities = pdf_score/pdf_score.sum()
list(zip(hypotheses, probabilities))


Out[204]:
[([0.3333333333333333, 0.3333333333333333, 0.3333333333333333],
  0.85202998933671381),
 ([0.8, 0.1, 0.1], 7.042002669045256e-08),
 ([0.1, 0.8, 0.1], 0.14768149981393544),
 ([0.1, 0.1, 0.8], 0.00028844042932409396)]