HP Forums
HP Prime and TI-84 Plus: Method of Equal Proportions: Number of U.S. Representative - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: HP Prime and TI-84 Plus: Method of Equal Proportions: Number of U.S. Representative (/thread-7266.html)



HP Prime and TI-84 Plus: Method of Equal Proportions: Number of U.S. Representative - Eddie W. Shore - 11-19-2016 03:13 PM

For more details, refer to the blog entry: http://edspi31415.blogspot.com/2016/11/hp-prime-and-ti-84-plus-method-of-equal.html

The Method of Equal Proportions: Determining the Number of Seats

In order to represent the population as fair as possible, methods must be used to distribute the number of seats. The method currently used is the Method of Equal Proportions, which has been in use since 1940.

The first step is to give each state one seat at the House of Representatives. For the United States, after each state gets one seat, there are 385 seats to assign.

The population of the states are recalculated by the following formula:

A_n = P / √(m * (m + 1))

where P = the state population, and m = the next potential seat (so for example, if the state currently has 5 seats, m = 6)

A recursive method, the method used in the program EQPROP is used:

A_1 = P / √2

A_n+1 = A_n * √(n/(n+2))

where n = the number the seats the state currently has


The Program EQPROP

The program EQPROP takes two arguments: the list of populations, and the number of House of Representative seats to be assigned. The program assumes that two Senators will also be assigned.

Output: A matrix of three columns:
Column 1: The population of each state. The population is sorted in descending order.
Column 2: The number of House Representatives.
Column 3: The number of House Representatives plus the 2 senators.


Code:
EXPORT EQPROP(lp,n)
BEGIN
// Method of equal proportions
// 2016-11-18 EWS
// population, no of seats

LOCAL la,s,lr,k,m,p,w;

// initialization
lp:=REVERSE(SORT(lp));
la:=lp/√2;
s:=n-SIZE(lp);
lr:=MAKELIST(1,X,1,SIZE(lp));

// loop
FOR k FROM s DOWNTO 1 STEP 1 DO
m:=MAX(la);
p:=POS(la,m);
w:=lr(p);
la(p):=la(p)*√(w/(w+2));
lr(p):=w+1;
END;

// output, organize matrix
// [population, senate, + house]
LOCAL l2,m2,l3;
l3:=lr+2;
l2:={lp,lr,l3};
l2:=TRN(list2mat(l2,3));
m2:=l2(1);
RETURN m2;

END;