# House of representatives apportionments
`houseofreps` implements apportionment methods for assigning seats in the US House of Representatives.
**Disclaimer: This product uses the Census Bureau Data API but is not endorsed or certified by the Census Bureau. See [Terms of Service](https://www.census.gov/data/developers/about/terms-of-service.html).**
Years supported:
```
1960, 1970, 1980, 1990, 2000, 2010, 2020
```
A detailed explanation of the current house seat apportionment algorithm can be found here: [https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html](https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html).
## Data source
The data source is from [https://www.census.gov](https://www.census.gov) and is completely described in the [data](data) folder.
## Installation
Local installation: clone the repo, then:
```
pip install -r requirements.txt
pip install -e .
```
## Tests
Tests are implemented for `pytest`. In the `tests` folder run:
```
pytest
```
## Discussion
It's fascinating to understand how seats in the US House of Representatives are assigned. Before this project, I had never thought about this problem:
* The US Senate consists of two senators for every US state - this is straightforward.
* The US House of representatives has members assigned based on the state's population. This leads to an immediate problem: the fraction of people residing in each state doesn't lead to an integer assignment of seats!
What can we do?
* Fractional voting - assign each state a fractional vote. With modern technology, this actually seems like the more reasonable approach. However, this is not how the US House of Representatives is currently assigned.
* An algorithm that assigns members to each state. For every state, a choice must be made - is the number of seats rounded up or rounded down? Either way, some state has to pay the price and receive less seats.
A detailed explanation of the current house seat apportionment algorithm can be found here: [https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html](https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html). Every 10 years, the number of seats is assigned based on the latest census data (most recently: 2020).
For completeness, the description of algorithm is copied here from [https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html](https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html), with some comments:
The method assigns seats in the House of Representatives according to a "priority" value. The priority value is determined by multiplying the population of a state by a "multiplier."
Let P represent a state's total population. **This already has questions, particularly regarding overseas service members, who excluded from the population counts in 1980 following the Vietnam war.**
All states start by receiving 1 seat. A state cannot receive less than one seat.
Next, let n represent the number of seats a state would have if it gained a seat (because all states automatically received one seat the next seat gained is "seat two," and the next "seat three," and the next "seat four," and so on.)
Now define the **multiplier**:
```
1/sqrt(n*(n-1))
```
[which is called the reciprocal of the geometric mean].
Thus the formula for calculating the multiplier for the second seat is:
```
1 / sqrt(2(2-1)) ~ 1/1.414213562 ~ 0.70710678
```
and the third seat is
```
1 / sqrt(3(3-1)) ~ 1/2.449489743 ~ 0.40824829
```
Once the "multipliers" have been calculated, the next step is to multiply this figure by the population total for each of the 50 states (**the District of Columbia is not included in these calculations**). The resulting numbers are the priority values.
Once you've calculated priority values for the total number of potential seats for each state, the next step is to rank and assign seat numbers to the resulting priority values starting with seat 51, until all 435 seats have been assigned (remember, each state automatically received one seat). Next, tally the number of seats for each state to arrive at the total number of seats in the House of Representatives apportioned to each state.
Raw data
{
"_id": null,
"home_page": "https://github.com/smrfeld/house-of-reps/",
"name": "houseofreps",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "smrfeld",
"author_email": "oliver.k.ernst@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/93/f5/95e97ea86171d7ad124c98f18417060ee4a712baf591740dd2be13b9a9dc/houseofreps-0.1.tar.gz",
"platform": null,
"description": "# House of representatives apportionments\n\n`houseofreps` implements apportionment methods for assigning seats in the US House of Representatives.\n\n**Disclaimer: This product uses the Census Bureau Data API but is not endorsed or certified by the Census Bureau. See [Terms of Service](https://www.census.gov/data/developers/about/terms-of-service.html).**\n\nYears supported:\n```\n1960, 1970, 1980, 1990, 2000, 2010, 2020\n```\n\nA detailed explanation of the current house seat apportionment algorithm can be found here: [https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html](https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html).\n\n## Data source\n\nThe data source is from [https://www.census.gov](https://www.census.gov) and is completely described in the [data](data) folder.\n\n## Installation\n\nLocal installation: clone the repo, then:\n```\npip install -r requirements.txt\npip install -e .\n```\n\n## Tests\n\nTests are implemented for `pytest`. In the `tests` folder run:\n```\npytest\n```\n\n## Discussion\n\nIt's fascinating to understand how seats in the US House of Representatives are assigned. Before this project, I had never thought about this problem:\n* The US Senate consists of two senators for every US state - this is straightforward.\n* The US House of representatives has members assigned based on the state's population. This leads to an immediate problem: the fraction of people residing in each state doesn't lead to an integer assignment of seats!\n\nWhat can we do?\n* Fractional voting - assign each state a fractional vote. With modern technology, this actually seems like the more reasonable approach. However, this is not how the US House of Representatives is currently assigned.\n* An algorithm that assigns members to each state. For every state, a choice must be made - is the number of seats rounded up or rounded down? Either way, some state has to pay the price and receive less seats.\n\nA detailed explanation of the current house seat apportionment algorithm can be found here: [https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html](https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html). Every 10 years, the number of seats is assigned based on the latest census data (most recently: 2020).\n\nFor completeness, the description of algorithm is copied here from [https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html](https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html), with some comments:\n\nThe method assigns seats in the House of Representatives according to a \"priority\" value. The priority value is determined by multiplying the population of a state by a \"multiplier.\"\n\nLet P represent a state's total population. **This already has questions, particularly regarding overseas service members, who excluded from the population counts in 1980 following the Vietnam war.**\n\nAll states start by receiving 1 seat. A state cannot receive less than one seat.\n\nNext, let n represent the number of seats a state would have if it gained a seat (because all states automatically received one seat the next seat gained is \"seat two,\" and the next \"seat three,\" and the next \"seat four,\" and so on.)\n\nNow define the **multiplier**:\n```\n1/sqrt(n*(n-1))\n```\n[which is called the reciprocal of the geometric mean].\n\nThus the formula for calculating the multiplier for the second seat is:\n```\n1 / sqrt(2(2-1)) ~ 1/1.414213562 ~ 0.70710678\n```\nand the third seat is\n```\n1 / sqrt(3(3-1)) ~ 1/2.449489743 ~ 0.40824829\n```\n\nOnce the \"multipliers\" have been calculated, the next step is to multiply this figure by the population total for each of the 50 states (**the District of Columbia is not included in these calculations**). The resulting numbers are the priority values.\n\nOnce you've calculated priority values for the total number of potential seats for each state, the next step is to rank and assign seat numbers to the resulting priority values starting with seat 51, until all 435 seats have been assigned (remember, each state automatically received one seat). Next, tally the number of seats for each state to arrive at the total number of seats in the House of Representatives apportioned to each state.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Apportionment of representatives in U.S. House of Representatives.",
"version": "0.1",
"project_urls": {
"Homepage": "https://github.com/smrfeld/house-of-reps/"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8d8f8c8436944fdc8d63d59aa71082f0f329318394c1f783b13ceff17cf7a379",
"md5": "2c906e9d09f87cc98419ec38a60bb4ef",
"sha256": "2f1986131e944c54ac1c4ae8afd006dcce0080af372912e0ee8f6c1ed0c87e7f"
},
"downloads": -1,
"filename": "houseofreps-0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2c906e9d09f87cc98419ec38a60bb4ef",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 24788,
"upload_time": "2023-11-12T19:35:12",
"upload_time_iso_8601": "2023-11-12T19:35:12.248005Z",
"url": "https://files.pythonhosted.org/packages/8d/8f/8c8436944fdc8d63d59aa71082f0f329318394c1f783b13ceff17cf7a379/houseofreps-0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "93f595e97ea86171d7ad124c98f18417060ee4a712baf591740dd2be13b9a9dc",
"md5": "ebf113b5f75577f2d779d4967d012805",
"sha256": "28742807b9f956f7f34b2a99921c5b53f9de12951c07452188be46521dbd53e5"
},
"downloads": -1,
"filename": "houseofreps-0.1.tar.gz",
"has_sig": false,
"md5_digest": "ebf113b5f75577f2d779d4967d012805",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 27906,
"upload_time": "2023-11-12T19:35:14",
"upload_time_iso_8601": "2023-11-12T19:35:14.352850Z",
"url": "https://files.pythonhosted.org/packages/93/f5/95e97ea86171d7ad124c98f18417060ee4a712baf591740dd2be13b9a9dc/houseofreps-0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-12 19:35:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "smrfeld",
"github_project": "house-of-reps",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "loguru",
"specs": [
[
"==",
"0.7.2"
]
]
},
{
"name": "mashumaro",
"specs": [
[
"==",
"3.10"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"1.26.1"
]
]
},
{
"name": "pandas",
"specs": [
[
"==",
"2.1.2"
]
]
},
{
"name": "plotly",
"specs": [
[
"==",
"5.18.0"
]
]
},
{
"name": "pytest",
"specs": [
[
"==",
"7.4.3"
]
]
},
{
"name": "setuptools",
"specs": [
[
"==",
"68.0.0"
]
]
},
{
"name": "tqdm",
"specs": [
[
"==",
"4.66.1"
]
]
}
],
"lcname": "houseofreps"
}