NaN from multinomial distribution at p=1


I’m getting NaN from a multinomial distribution, where I expected 1. Is this a bug or am I doing something wrong?

using Distributions
dist = Multinomial(2, [0.999,0.001])
pdf(dist,[2,0]) ## 0.998, ok

dist = Multinomial(2, [1.0,0.0])
pdf(dist,[2,0]) #NaN, not ok

The equivalent limit of the binomial has no problem:

pdf(Binomial(1,0.999),[0,0.5,1])  ## [0.001, 0.0, 0.999] 
pdf(Binomial(1,1.0),[0,0.5,1])    ## [0.0,   0.0,  1.0]


You are getting a NaN from a 0^0, which is correct. See the PMF of a multinomial.

EDIT: correcting my mistake — in these contexts it is customary to interpret 0^0=1. See the famous “Two notes on notation” paper by Knuth for example.


The formula has a 0^0, I’m sure this is what’s causing the NaN.

But the limiting distribution puts all the mass on one point, and this limit is what I was hoping the function would return.

This works for the binomial case, where again the simple formula has an indefinite 0^0, but I guess someone has caught the special case.


Maybe file a bug against Distributions.


OK, I made issue 675.

I also had a brief look at the code but am way out of my depth!