Function Repository Resource:

# RoundedPercentageAllocation

Split a value into list of rounded numbers according to a list of target proportions

Contributed by: Jon McLoone
 ResourceFunction["RoundedPercentageAllocation"][total,proportions] creates a list of integers that sum to total and are also as close to the given proportions as possible. ResourceFunction["RoundedPercentageAllocation"][total,proportions,d] creates a list of numbers that sum to total and are multiples of d.

## Examples

### Basic Examples (2)

Split 100 into proportions of 1/3 and 2/3 to the nearest integer:

 In[1]:=
 Out[1]=

In most financial currencies, one would typically allocate it to the nearest 0.01:

 In[2]:=
 Out[2]=

### Properties and Relations (2)

As long as the total is a multiple of the allocation amount, the result will always sum to the original total:

 In[3]:=
 Out[2]=
 In[4]:=
 Out[4]=
 In[5]:=
 Out[5]=
 In[6]:=
 Out[6]=
 In[7]:=
 Out[7]=

However, the proportions in the result are usually not exactly the requested proportions:

 In[8]:=
 Out[8]=

### Possible Issues (2)

If the input number is not divisible by the allocation size then the result will add up to less then the original:

 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=

If you allocate an amount to proportions that do not sum to one, the proportions will be rescaled so that they do sum to 1:

 In[11]:=
 Out[11]=

Jon McLoone

## Version History

• 1.0.0 – 05 February 2020