Description Usage Arguments Details Value Examples

Produce an integer vector approximation of a non-increasing non-negative numeric vector such that it sums to an positive integer

1 | ```
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 |

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.

An integer vector

1 | ```
int_approx(c(3.7, 3.2, 2.4, 1.5))
``` |

talegari/sidekicks documentation built on Sept. 26, 2018, 4:18 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.