# How to Fix the House of Representatives

How to Fix the House of Representatives

## The representation in Congress is poorly distributed across states. How can we improve this?

The representation in Congress is poorly distributed across states. How can we improve this?

### Loading the Data

Loading the Data

While Mathematica has population conveniently built in to state entities through the Wolfram Data Repository, let’s be extra careful and load the same decennial Census figures the government has used for apportionment, as well as the official number of representatives per state allotted every tens years. The historical data is drawn from Census.gov in the Notebook linked at the top of this Notebook and published to the Cloud:

Clear["Global`*"];

censusData = CloudGet["https://www.wolframcloud.com/objects/1a4bfb31-d5d4-49e3-9e04-4cf80e1fae1b"];

stateAbbrs = Keys@censusData;

(* We need a list of state abbreviations without DC since it is not factored into allocation -- "Taxation

Without Representation!" *)

stateAbbrs50 = Select[stateAbbrs, # != "DC"&];

In[]:=

## How apportionment works: The Huntington-Hill method

How apportionment works: The Huntington-Hill method

The Constitution stipulates that the number of representatives per state should be reapportioned after each decennial census based on state populations. It does not specify the total number of representatives or the exact method of allotment, other than specifying that each state should have at least one representative.

Since the 1940 Census, the United States has used the Huntington-Hill algorithm, known as the "method of equal proportions," to divvy up the 435 House seats. This begins by allotting one seat to each state, leaving 385 remaining. The 50 states are then allocated these remaining seats one-by-one according to which one has the highest priority according to a simple equation: its population divided by the square root of its current seats times one extra seat (the Geometric Mean):

P

n(1+n)

Lets recreate this method

HuntingtonHill[stateAbbr_, stateReps_] := 1.0 * censusData[stateAbbr]["population_decennial"]["2010"] /

Sqrt[stateReps * (stateReps + 1)]

In[]:=

The allocation function will assign electoral votes according to the above formula one at a time. To save computational time, we’ll store the priorities until we update the number of seats in a state rather than run 50 square roots 385 times.

ApportionOne[reps_, priorities_] :=

topPriority = First[Keys[priorities]];

updatedPriorities = priorities;

updatedReps = reps;

updatedReps[topPriority] += 1;

updatedPriorities[topPriority] = HuntingtonHill[topPriority, updatedReps[topPriority]];

{ updatedReps, Reverse@Sort@updatedPriorities }

;

In[]:=

Since we might want to tinker with the size of the House, let’s make that a parameter, total_, in the function that runs the entire apportionment. It will return an association with the final apportionment as well as a list of the order in which the states received seats and which state WOULD have received the next see if one more slot had been available.

CalculateApportionment[total_:435]:=

(* Assign one to each state, per the Constitution *)

stateReps = AssociationThread[stateAbbrs50, ConstantArray[1, 50]];

(* Keep track of the order in which the remaining (total - 50) seats are assigned by Huntington-Hill *)

statePriorities = Reverse@Sort@AssociationThread[stateAbbrs50, HuntingtonHill[#, 1]& /@ stateAbbrs50];

seatOrder = {};

While[Total@stateReps < total,

seatOrder = Append[seatOrder, First@Keys@statePriorities];

{ stateReps, statePriorities } = ApportionOne[stateReps, statePriorities];

];

nextSeatWouldBe = First@Keys@statePriorities;

<| "apportionment" stateReps, "order" seatOrder, "next" nextSeatWouldBe, "size" total |>

;

In[]:=

### Did it work?

Did it work?

computedApportionment = CalculateApportionment[435];

actualApportionment = AssociationThread[stateAbbrs50, censusData[#]["representatives"]["2010"]& /@

stateAbbrs50];

computedApportionment["apportionment"] - actualApportionment

In[]:=

AK0,AL0,AR0,AZ0,CA0,CO0,CT0,DE0,FL0,GA0,HI0,IA0,ID0,IL0,IN0,KS0,

KY0,LA0,MA0,MD0,ME0,MI0,MN0,MO0,MS0,MT0,NC0,ND0,NE0,NH0,NJ0,NM0,

NV0,NY0,OH0,OK0,OR0,PA0,RI0,SC0,SD0,TN0,TX0,UT0,VA0,VT0,WA0,WI0,

WV0,WY0

Out[]=

### Sure did ! There difference between the calculated apportionment and the actual one is zero all around

Sure did ! There difference between the calculated apportionment and the actual one is zero all around