From: Fred Smith on
I have percentages in B2:B30 which add up to 100%, and an amount to allocate
in A2 (for example, 8). However, the results must be integers, and must add
up to A2. The simple formula is =round($A$2*B2,0) copied down, but the
rounding doesn't always produce the right total. How do I ensure that the
total always equals A2?

Thanks,
Fred

From: Joe User on
"Fred Smith" <fsmith11(a)yahooo.com> wrote:
> I have percentages in B2:B30 which add up to 100%,
> and an amount to allocate in A2 (for example, 8).
> However, the results must be integers, and must add up to A2. The simple
> formula is =round($A$2*B2,0)
> copied down, but the rounding doesn't always produce
> the right total. How do I ensure that the total always
> equals A2?

I believe I already answered that in Lilyput's thread. I'll paraphrase....

This is a common quantization problem, i.e. the result of rounding "long"
decimal fractions to fewer decimal places (or integers). There are no
perfect solutions.

Consider the following simple example. You have 3 dollar bills, and you
want to award them to 4 people in the proportion to their contributions,
which is 25% each. It can't be done! At least, not fairly. Someone must
get zero.

One simple (but flawed) approach is to put the following formulas into C2
and C3, say, and copy C3 down through C30:

C2: =ROUND($A$2*B2,0)

C3: =MIN($A$2 - SUM($C$2:C2), ROUND($A$2*B3,0))

That approach is flawed because it is more unfair to the people represented
by the later cells.

We might ameliorate the unfairness by randomizing B2:B30 (and associated
columns), using the formula above, then reordering C2:C30 according to the
original order. I would use a UDF for that.

From: Joe User on
PS....
> One simple (but flawed) approach is [....]

I seem to recall posting (or at least preparing for posting or email) a
solution to another similar problem that ameliorated the unfairness by
ensuring that everyone gets at least one (if they deserve it), then everyone
gets at least two (if they deserve it), etc per the OP's request.

Some people might consider that to be more fair, even if it means that a 50%
contributor might get the same as everyone else due to quantization.

I don't remember if my approach worked. But if that's something that
Lilyput would like to consider, I can search for it.

(It's a difficult search for me. So I don't want to start doing it unless
there is some interest.)


----- original message -----

"Joe User" <joeu2004> wrote in message
news:%232xgqF9lKHA.3840(a)TK2MSFTNGP06.phx.gbl...
> "Fred Smith" <fsmith11(a)yahooo.com> wrote:
>> I have percentages in B2:B30 which add up to 100%,
>> and an amount to allocate in A2 (for example, 8).
>> However, the results must be integers, and must add up to A2.
>> The simple formula is =round($A$2*B2,0)
>> copied down, but the rounding doesn't always produce
>> the right total. How do I ensure that the total always
>> equals A2?
>
> I believe I already answered that in Lilyput's thread. I'll
> paraphrase....
>
> This is a common quantization problem, i.e. the result of rounding "long"
> decimal fractions to fewer decimal places (or integers). There are no
> perfect solutions.
>
> Consider the following simple example. You have 3 dollar bills, and you
> want to award them to 4 people in the proportion to their contributions,
> which is 25% each. It can't be done! At least, not fairly. Someone must
> get zero.
>
> One simple (but flawed) approach is to put the following formulas into C2
> and C3, say, and copy C3 down through C30:
>
> C2: =ROUND($A$2*B2,0)
>
> C3: =MIN($A$2 - SUM($C$2:C2), ROUND($A$2*B3,0))
>
> That approach is flawed because it is more unfair to the people
> represented by the later cells.
>
> We might ameliorate the unfairness by randomizing B2:B30 (and associated
> columns), using the formula above, then reordering C2:C30 according to the
> original order. I would use a UDF for that.

From: Joe User on
Errata....

I wrote:
> We might ameliorate the unfairness by randomizing
> B2:B30 (and associated columns), using the formula
> above, then reordering C2:C30 according to the original order. I would
> use a UDF for that.

I suspect most people (those represented by B2:B30) would not consider that
to be less unfair.

It would probably be more fair to effectively sort B2:B30 in descending
order, then apply the distribution. Again, you could reorder C2:C30
according to the original order, if need be; and in that case, I would use a
UDF.


----- original message -----

"Joe User" <joeu2004> wrote in message
news:%232xgqF9lKHA.3840(a)TK2MSFTNGP06.phx.gbl...
> "Fred Smith" <fsmith11(a)yahooo.com> wrote:
>> I have percentages in B2:B30 which add up to 100%,
>> and an amount to allocate in A2 (for example, 8).
>> However, the results must be integers, and must add up to A2. The simple
>> formula is =round($A$2*B2,0)
>> copied down, but the rounding doesn't always produce
>> the right total. How do I ensure that the total always
>> equals A2?
>
> I believe I already answered that in Lilyput's thread. I'll
> paraphrase....
>
> This is a common quantization problem, i.e. the result of rounding "long"
> decimal fractions to fewer decimal places (or integers). There are no
> perfect solutions.
>
> Consider the following simple example. You have 3 dollar bills, and you
> want to award them to 4 people in the proportion to their contributions,
> which is 25% each. It can't be done! At least, not fairly. Someone must
> get zero.
>
> One simple (but flawed) approach is to put the following formulas into C2
> and C3, say, and copy C3 down through C30:
>
> C2: =ROUND($A$2*B2,0)
>
> C3: =MIN($A$2 - SUM($C$2:C2), ROUND($A$2*B3,0))
>
> That approach is flawed because it is more unfair to the people
> represented by the later cells.
>
> We might ameliorate the unfairness by randomizing B2:B30 (and associated
> columns), using the formula above, then reordering C2:C30 according to the
> original order. I would use a UDF for that.

From: Joe User on
Errata (again)....

I wrote:
> One simple (but flawed) approach is to put the following
> formulas into C2 and C3, say, and copy C3 down through C30:
> C2: =ROUND($A$2*B2,0)
> C3: =MIN($A$2 - SUM($C$2:C2), ROUND($A$2*B3,0))

I think C30 should have the formula:

C30: =$A$2 - SUM($C$2:C29)

That may be necessary to remedy the case where SUM(C2:C29)+ROUND(A2*B3,0) is
less than A2.

At least, I __think__ that is a possibility. In any case, the
non-generalization cannot hurt, even it proves to be surperfluous.


----- original message -----

"Joe User" <joeu2004> wrote in message
news:%232xgqF9lKHA.3840(a)TK2MSFTNGP06.phx.gbl...
> "Fred Smith" <fsmith11(a)yahooo.com> wrote:
>> I have percentages in B2:B30 which add up to 100%,
>> and an amount to allocate in A2 (for example, 8).
>> However, the results must be integers, and must add up to A2. The simple
>> formula is =round($A$2*B2,0)
>> copied down, but the rounding doesn't always produce
>> the right total. How do I ensure that the total always
>> equals A2?
>
> I believe I already answered that in Lilyput's thread. I'll
> paraphrase....
>
> This is a common quantization problem, i.e. the result of rounding "long"
> decimal fractions to fewer decimal places (or integers). There are no
> perfect solutions.
>
> Consider the following simple example. You have 3 dollar bills, and you
> want to award them to 4 people in the proportion to their contributions,
> which is 25% each. It can't be done! At least, not fairly. Someone must
> get zero.
>
> One simple (but flawed) approach is to put the following formulas into C2
> and C3, say, and copy C3 down through C30:
>
> C2: =ROUND($A$2*B2,0)
>
> C3: =MIN($A$2 - SUM($C$2:C2), ROUND($A$2*B3,0))
>
> That approach is flawed because it is more unfair to the people
> represented by the later cells.
>
> We might ameliorate the unfairness by randomizing B2:B30 (and associated
> columns), using the formula above, then reordering C2:C30 according to the
> original order. I would use a UDF for that.