avoid numerical instability of multinomial
fix for MSVC OMP bug