When the "sum" function returns nan or -nan


I wonder when “sum” function returns nan or -nan value.

Would anyone mind letting me know a specific page in stan manual, if exists?

I’m heading to this occasional error message, so asking this question.

" Exception: multinomial_rng: Probabilites parameter is not a valid simplex. sum(Probabilites parameter) = -nan, but should be 1

Thanks in advance.


I don’t think there is a specific page about it in the Stan manual, but it means that one or more of the elements of the vector being summed are NaN (or that one is positive infinity and the other is negative infinity, but that should not be happening with a simplex).


Thanks, Ben!


Hi Ben, I’m sorry to call you like this way, but do you have any idea to handle this precision problem? This is not a problem in rstan, so I didn’t post it in this website. However, if you don’t mind, I’d like to hear your valuable opinions.