change nparray.nonzero() to nparray.argmax() to get a sample from multinomial