Currently, Distributions does not have a method for the CDF of the Multinomial distribution. Another user on Discourse proposed a solution which I reproduce below. If this would be acceptable, I can submit a PR and add some tests.
using Distributions
using Combinatorics
padded_partition(c, s, tmp) = foldl((r,x) -> (r[x]+=1; r), s; init=((tmp .= 0;tmp)))
function MultinomialCDF(D, c)
k = length(c)
tmp = zeros(Int, k)
return sum(s -> pdf(D, padded_partition(c, s, temp)),
multiset_combinations(1:k, c, D.n))
end
D = Multinomial(5, 3)
# upper bounds on n
c = [2,3,4]
MultinomialCDF(D, c)
@ParadaCarleton, I'd be happy to make a PR later this week. After I posted this issue, another user posted a more efficient solution. It might be worth considering that. The only thing I would need is guidance on licensing.
Hi,
Currently, Distributions does not have a method for the CDF of the Multinomial distribution. Another user on Discourse proposed a solution which I reproduce below. If this would be acceptable, I can submit a PR and add some tests.