Princeton Election Consortium

A first draft of electoral history. Since 2004

Meta-Margins for control: House D+2.8% Senate R+5.6% Find key elections near you!

MATLAB – gerrymandering code – delegations.m

ifirst=[1 8 9 18 22 75 82 87 88 115 128 131 133 151 160 164 168 174 180 182 190 199 213 221 225 233 234 237 241 243 255 258 285 298 299 315 320 325 343 345 352 353 362 398 402 403 414 424 427 435 436];

dsim=0;dactual=0;
for j=1:50
sdist=[ifirst(j):ifirst(j+1)-1];
gerry
p1(j)=outs(2);p2(j)=outs(3);
pmin(j)=min(outs(2:3));
seats_sim(j)=outs(4);
seats_act(j)=s_dseats;
% do something with outputs
dsim=dsim+outs(4);
dactual=dactual+s_dseats;
end
dsim
dactual
diffs=seats_act-seats_sim;
hist(diffs,[-3.7:0.2:3.2])
grid on
xlabel(‘Difference from simulated mean outcome (seats)’)
ylabel(‘Number of seats’)
sum(diffs(or(diffs<-1.2,diffs>1.2)))