int_approx.Rd
Produce an integer vector approximation of a non-increasing non-negative numeric vector such that it sums to an positive integer
int_approx(vec, n)
vec | non-decreasing non-negative numeric vector |
---|---|
n | A positive integer to which vector should sum to. Default value is the rounded sum of the vector |
An integer vector
The numeric vector is scaled to sum to n. Then, an integer vector is assigned the integer parts of the scaled vector. The leftout part of the sum is distributed based on the magnitude of the fractional part. This kind of approximation is useful when an algorithm produces ranking scores which have to allocated with positive integer constraints.
#> [1] 4 3 2 2