Percentage total amongst multiple numbers

wannabeafrog's icon

Hello

I'm currently working on a patch in which the user should be able to set himself the probabilities of certain events, to do this, I arranged some number boxes in which a total 100% is divided equally, what I want to do is substract numbers from the rest of the boxes whenever you increase the number in one of them, so they always sum up 100. Any ideas on how to accomplish this?

Example in case I didnt make myself clear:

[25] [25] [25] [25] = total 100%

If I added 3 to the first number box it should ideally do this:

[28] [24] [24] [24] = total 100%

Of course theres a lot of interrogants, as in which order should he substract or if it is possible to do with floats (this would be even better)

Thanks a lot in advance.

ch's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You could maybe approach it this way :

Roman Thilenius's icon

this reminds me on my various approaches to do the same for a variable
number of gain regulators, where i needed to have a variable sum in addition.

try to realize it with "set" messages only at first, then you will see at which points
you need to have a pvar or something like that, where the state of the parameters
is copied in order to accumulate.

-110

Daxel Ghost's icon

Years later, while i'm trying to do something similar to wannabeafrog, looking for some solution in the forum, seems that

Pasted Max Patch: Click to Expand
You could maybe approach it this way :

is the only acceptable solution, since according to my experience with the number box/dial and set message (i didn't used pvar , however) the number floating between +1/+2 from the final number, and never returns accurate.

The only thing on CH solution, is that if only one data is selected and sended, it returns 0 or 100, dividng the sum of one element by themself and multiplying by 100.

does anyone know a better solution?
This is my version, made to choose the percentage among five random velocity groups:

Max Patch
Copy patch and select New From Clipboard in Max.

Daxel Ghost's icon

The only thing on CH solution, is that if only one data is selected and sended, it returns 0 or 100, dividng the sum of one element by themself and multiplying by 100.

Max Patch
Copy patch and select New From Clipboard in Max.

I think i solved that problem.