All problems
Dirichlet-Multinomial Probability
Problem
Dirichlet-multinomial probability of a count vector given Dirichlet concentration parameters alphas:
P(counts) = n! / prod(c_i!) * Gamma(A) / Gamma(A + n) * prod(Gamma(a_i + c_i) / Gamma(a_i))
where A = sum(alphas) and n = sum(counts). Return 0.0 for negative counts or nonpositive alphas.
Hint
Combine the multinomial coefficient with the Dirichlet Beta-ratio term.
Test cases
case 1
in: [[1,1],[1,1]]
expected: 0.3333333333333332
case 2
in: [[2,0],[1,1]]
expected: 0.3333333333333332
case 3
in: [[1,1,1],[1,1,1]]
expected: 0.09999999999999994
case 4
in: [[2,1],[2,3]]
expected: 0.2571428571428569
Starter codePython
import math
def dirichlet_multinomial_probability(counts, alphas):
# Your code here
pass4 test cases · run your code against them in the editor