I'm trying to use the multinominal.pmf
function from scipy.stats
(python).
When I use this function where all probabilities in the input bigger than zero, it work fine. The problem is when I want to use the function when one of the probabilities is zero.
The following example shows what I mean:
In [18]: multinomial.pmf([3, 3, 0], 6, [1/3.0, 1/3.0, 1/3.0])
Out[18]: 0.027434842249657095
In [19]: multinomial.pmf([3, 3, 0], 6, [2/3.0, 1/3.0, 0])
Out[19]: nan
As can be seen, in the first time where all probabilities > 0 there is no problem to use the function. However when I change one of the probabilities to zero, the function return nan
, even through the function should return 0.21948
.
Is there a way (in python) to calculate the pmf when one of the probabilities is zero? either another way that can handle it, or a work around for this function.
additional info
The value that the function in the example should have returned I calculated using mnpdf function in matlab. However since the rest of my code is in python I prefer to find a way to calculate it in python.