I'm trying to generate a set of random numbers that sum to some total in some range.
This problem is probably best described by example.
Say I want to generate 532 random numbers between 1 and 8 whose sum is equal to 1000. How could I achieve this? The application of this doesn't require a uniform distribution just some form of random numbers.
I did find that when using python, numpy can accomplish this via the following (without the range constraints)
numbers = numpy.random.multinomial(1000, numpy.ones(523)/523, size=1)[0]
This is great, however, I am looking for a C# solution as my project is written in .Net
Aucun commentaire:
Enregistrer un commentaire