added robust multinomial calculation used in Jie's model (but not in a class, darn)