I'm trying to draw an numpy 2D-array of shape (N,5) from a certain probability distribution (in my case a Zipf distribution) but with the condition that the sum of all array elements ends up being equal to a certain value of type float. (in the following named K)
I have currently not really an idea how it could be done beside just redrawing until it appears randomly. (But that is of course an insane inefficient idea in that sense). I am currently using the builtin numpy function for random arrays of the Zipf distribution and I am running python 3.7:
v2 = K * numpy.random.zipf(2, (N,5))
So is there any way to do what I want to do in an elegant/efficient manner? (also nonefficient but practical solutions are welcome). Maybe there is some nice python (or julia) module that could help?
EDIT: Something I did not think about was of course just scaling the resulting array of my random draw above. Anyway, if there are more "elegant"/modular solutions, it might be more pleasing as a solution.