Hi,

I'd like to randomly populate a numpy array (100,100) so that the numpy.sum() of the array equals exactly 300
(e.g. distribute 300 rice grains on a chess board). The final array should only contain integers (so no floats) from 
0 to X (max 300).  Furthermore I'd like to use a weighing factor, so that some of my array-cells are more probably to
be populated than others. Therefore I have an array of the same size (100,100) and that is in numpy.sum = 1:

x = numpy.random.random_sample((10,10))
y = x/numpy.sum(x)

Some side conditions: Of course if one cell has exactly 0 as weighing factor, also the result has to be 0 for that
cell. If only one cell has a weighing factor at all (all others are 0) the entire 300 has to be assigned to that cell.

Can that easily be achieved with Scipy/Numpy?

Thank you so much for your help,

Johannes