Given a real numbers yi with the particular property that ∑iyi is integer, find integer numbers xi
which are close to yi (c("", "\n", "∣x[i]−y[i]∣<1foralli")), and have identical marginal
sum, sum(x) == sum(y).
As I found later, the problem is known as Apportionment Problem
and it is quite an old problem with several solution methods proposed historically, but only in 1982, Balinski and Young proved that there is no method that fulfills three natural desiderata.
Note that the (first) three methods currently available here were all (re?)-invented by M.Maechler, without any knowledge of the litterature. At the time of writing, I have not even checked to which (if any) of the historical methods they match.
method: character string specifying the algorithm to be used.
Details
Without hindsight, it may be surprising that all three methods give identical results (in all situations and simulations considered), notably that the idea of mass shifting employed in the iterative "1greedy" algorithm seems equivalent to the much simpler idea used in "offset-round".
I am pretty sure that these algorithms solve the Lp
optimization problem, minx∣∣y−x∣∣p, typically for all pin[1,Inf]
simultaneously, but have not bothered to find a formal proof.
Returns
a numeric vector, say r, of the same length as x, but with integer values and fulfulling sum(r) == sum(x).
Author(s)
Martin Maechler, November 2007
References
Michel Balinski and H. Peyton Young (1982) Fair Representation: Meeting the Ideal of One Man, One Vote ;