Apportion travis yard docs code climate

A Ruby implementation for apportionment


Apportionment is most often associated with the US Congressional apportionment, using the Equal Proportions (or Huntington-Hill) method.

In general, apportionment involves the division of a scarce resource among recipients, according to a pre-determined set of recipient weights. Further, a series of apportionments might occur over time, with each new apportionment overlaying the previous.

Different domains might make use of apportionment. One example is the allocation (or distribution) of sellable inventory among a number of retail stores, according to the expected sales rate for each store. For this usage, recipients would likely begin an apportionment with varying quantities of existing inventory.

Other apportionment methods exist, notably the Quota method, that address issues with Equal Proportions.


Add this line to your application's Gemfile:

gem 'apportion'

And then execute

$ bundle

Or install it yourself as

$ gem install apportion


Apportion.division(weights, size, options = {})

Returns a hash (a key for each recipient) with the size quantity distributed among recipients (as values)


weights (required) a [Hash] of relative integer proportions for each recipient

size (required) an [Integer] quantity to apportion

options (optional) [Hash] keys

  • :prior_portions a [Hash] prior portions for each recipient from a previous apportionment
  • :required_minimum an [Integer] smallest portion for each recipient


To install dependencies

$ bundle

To run the tests

$ rake


The gem is available as open source under the terms of the MIT License.