How to get N random integer numbers whose sum is equal to M
问题 I want to make a list of N random INTEGER numbers whose sum is equal to M number. I have used numpy and dirichlet function in Python, but this generate double random number array, I would like to generate integer random number. import numpy as np np.random.dirichlet(np.ones(n))*m The solution can use other distribution the sense is resolve the problem. 回答1: The problem with using dirichlet for this is that it is a distribution over real numbers. It will yield a vector of numbers in the range