-->

Multinomial Distribution in python

2019-07-21 00:03发布

问题:

I am trying to translate some Julia code to Python. This is code for the multinomial distribution, and I am stuck in the last part of the it. I don't know how to write it in Python, because I want to know if there is a package that will do what I want. I don't know if I can do this using SciPy.stats, because the documentation seems kind of limited.

Here you will find a part of the Julia code where I'm stuck: x1s is an array, x also is an array, OrthoNNDist is a name of a struct:

Base.length(d::OrthoNNDist) = length(d.x0)

Distributions.rand(d::OrthoNNDist) = rand(d.x1s)

Distributions.pdf(d::OrthoNNDist, x::Vector) = x in d.x1s ? d.prob : 0.0
Distributions.pdf(d::OrthoNNDist) = fill(d.prob, size(d.x1s))
Distributions.logpdf(d::OrthoNNDist, x::Vector) = log(pdf(d, x))