Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say you have a set of ideal ratios, whose sum = 1. For example,

input = [0.2, 0.2, 0.3, 0.3]

But suppose that there is a rule stating that every ratio should be either 0 or less than 0.25. Intuitively we can say some answers include:

output = [0, 0, 0.5, 0.5]
output = [0.25, 0.25, 0.25, 0.25] 
output = [0, 0.25, 0.375, 0.375]

But the sum of the differences from the ideal_set is 0.8 for the first answer, 0.2 for the second, 0.5 for the third, so the first is superior.

Is there an algorithm/formula to automatize this normalization?

share|cite|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.