A requested number of random numbers giving a certain sum

Lê Quan Ninh's icon

Hello,
Is it possible within Max to generate a certain number of random numbers giving a desired sum ?

For instance :
9 numbers (from 50) giving a sum of 2640 ?

Thanks in advance,

Ninh

$Adam's icon

Hi,

this is in fact not a Max, but a general math question. You have to find out how you want to get those random numbers, then you can do it with Max... Either you can take random values and then scale them in order to keep their sum constant; or you can generate the random numbers one-by-one and decrease the random domain after each step in order to make sure that the sum of the numbers would still remain constant; or you find some other way to go. After finding out the proper solution for your particular case, you can go and create a patch that realizes that particular solution.

Hope this helps,
Ádám

Roman Thilenius's icon

i would go the route to scale stuff to a range from 0. 1.

Lê Quan Ninh's icon

A million thanks to you guys !

Roman Thilenius's icon

btw, i just played a bit with that query - of course you must also ask yourself what distribution you want.