lundi 8 juin 2020

How to generate constrained uniform random numbers with a fixed sum?

I want to generate an array of uniformly distributed random numbers constrained between the values a and b such that for each element x in the array, a<=x<=b. The sum of all elements in the array should equal s. Assume that n such numbers have to be generated.

The arguments are such that n*a<=s<=n*b.

There is a function 'randfixedsum' in MATLAB by Robert Stafford which does this. What I am looking for is a generalized algorithm to replicate this in fortran. Any references/tips on getting started would also be appreciated.




Aucun commentaire:

Enregistrer un commentaire