Monday, December 2, 2019

Anarchocapitalism and The Vulnerable World Hypothesis

Anarchy in the 21st CenturyAnarchocapitalism (AC) is quite the interesting political and economic philosophy that is more plausible than one might initially suspect. It is a subset of anarchist thinking, where our capitalist economic system would extend to all aspects of society, including law, politics, healthcare, and more.
Unlike other anarchist philosophies that optimistically (unless you think AGI isn’t optimistic) hope for a better world without any clear mechanism for how such a society would realistically structure itself without at least some market structure (socialist/communist based anarchy), AC merely proscribes an extension of our market system to all aspects of human interaction.
David Friedman, a renowned legal economist, is perhaps the world’s leading proponent of this anarchist school of thought, espoused thoroughly and articulately in The Machinery of Freedom. As he sees it, the problem with the minarchist position (a libertarian government based on the absolute minimal government possible) compared to full blown anarchy is if you think the government is bad at producing shoes, cars, and pork, then what makes you think it would be good at producing the legal framework in which we trade said goods?
David Friedman described the difference between his more radical position and his father’s, Milton Friedman, the legendary libertarian and Nobel Prize winning economist, as Milton thought AC might work, but probably wouldn’t, while David thought AC might not work, but probably would.*
Here, I will first provide an overview of AC, attempting to defend it against superficial arguments. I won’t address moral arguments for AC from proponents such as Murray Rothbard,** but instead look at consequentialist arguments (due to the “positive” prediction that such a world would look positive). I argue that AC would be neither stable (hence possible) nor libertarian based on Nick Bostrom’s recent paper “The Vulnerable World Hypothesis.”
*From now on, I’ll be referring to David Friedman, unless otherwise stated.
**I agree with Friedman that such moral arguments are not well grounded.
Source: Atlas Society
Violence, The Most Obvious Rejection of AC
As surprising as it may sound to the uninformed, Ayn Rand was not nearly the most radical capitalist. In fact, she argued against AC, concluding that a full extension of capitalism would lead to a war of each against all. This school of objectivism therefore requires a minimal amount of government to defend property rights, rule of law, and free markets.
Rand couldn’t see a mechanism for solving legal, and especially criminal, matters without centralized government. If I’m bigger than you, then I can bully you into giving me whatever I want. However, as Friedman rightfully points out, even primitive animals exhibit a natural defense of property rights that clearly needs no centralization.
The stable equilibrium is for animals to defend their own territory, even to the point of incurring large costs, but not to attack others unless they have a significant physical advantage. (In many ways, this is the evolutionary basis of loss aversion.) Constant war is simply too costly, although certainly not entirely avoidable.
Since under AC there’s a market for everything, security and insurance firms would evolve to protect you from your neighbor stealing your wife. If you both hire the same neighborhood security contractor SecureMe, they would have an incentive to accurately investigate violations to maintain their reputation and prevent you from joining their biggest competitor SecurityRUs.
What if SecurityRUs and SecureMe have a beef? Since we are talking (in game theoretic terms) of a repeat game, competitors would agree in advance to avoid physical conflict and arbitrate any disputes with the reputable Judge Judy, who is known as being fair and totally not obnoxious.
And, much like Android, iOS, and Windows evolved in a competitive landscape, the invisible hand would create a mesh network of laws, conducive to local customs while general enough to allow international commerce.
What about if you get hit by an uninsured mobster? Every company would have an incentive to pool funds and establish jails. If you can’t afford insurance, hopefully a family member could spot you for a couple of years.
While that may seem like a cut throat society, as an economist, you can’t simply dismiss apriori the negative consequences of the welfare state or the possibility that private charities may get crowded out by government funds.* The AC argues that on net balance such a world would be far preferable by assuming only moderate libertarian beliefs.
Many are rightfully skeptical at this point as to whether or not this system could scale in all situations. The AC would point to ancient Viking societies and our modern privately arbitrated tech patent resolutions as plausible real world alternatives to centralized legal systems, ranging from the size of a village to global corporations.
Additionally, they would point out that our current approach is far from perfect, from racially biased criminal justice systems based on rent seeking prison profiteers to state sanctioned human rights violations. I, for one, am eager to listen to any radical suggestion for prison reform, because our current system destroys lives and generally sucks. Then again, I’m not so sure an entirely free market prison system is moving towards the correct trajectory on this one.
On the other hand, such a hypothetical AC world would likely be libertarian, since I am willing to pay dearly to prevent you from selling me into slavery but not so willing to prevent you from doing bath salts. So, drugs and prostitution would likely be legal, but violent crime would not.
As long as you don’t break into my house to steal my opioids, we’re all good. If not, then I have a right to use a bazooka on your tweeking ass, happily collecting my reimbursement check for a new front wall (assuming a willing underwriter).
As absurd as much of this may sound, private security firms thrive in countries where government enforcement is weak, such as Central and South America and Africa. Personally, I don’t find fault with experimenting in part with decentralized forms of legal structure. What is bitcoin, after all?
Instead, I believe edge cases could prove the downfall of such a system, perhaps where a small group of individuals amass too much power and de facto create a centralized government. Hence, I question the stability of AC over infinite time periods, but for now, let us grant that AC would remain stable by assuming competitive pressures would equalize or at least limit individual power over time.
*In some sense, this is the ultimate antifragile/ skin in the game system, although Nassim Taleb would likely reject it as unstable due to the minority rule.
A Flaw in DemocracyIn fact, ACs like Friedman claim a general argument against government. Namely, concentrated interests beat dispersion every time. The Confederation of Copper Coin Companies will lobby to keep the penny as currency, even though each of us individually fucking hates pennies.
At the same time, voters are incompetent, not because they are stupid, but because they have no incentive to spend hours watching political commentary when their vote is insignificant compared to the trillions spent lobbying. While most would argue this is a necessary evil, the AC asks if you would really miss your local sleazy politician who you usually only agree with 60% of the time anyway?
Textbook Microeconomics: Sell the Streets, and Everything ElseWhat does your stereotypical out of touch academic economist say about AC? Well, as long as we assume homogenously exogoneously uniform transitive rational preferences, infinitesimal market size, symmetric information, perfect competition, and no externalities in all markets, no economist would ever object to AC. But while a perfect representation of your classroom economist, this is an unfair caricature of AC.
Libertarians have been arguing for decades that private monopolies and cartels are notoriously difficult to maintain without government intervention/regulation (support). If a company is making extremely high profits, rest assured other big companies would want a piece of the action. I actually have quite a bit of sympathy for this view, as historically, most monopolies are supported by heavy regulation that raises the barriers of entry to potential smaller competitors.*
Open up Xfinity to thousands of local entrepreneurs and their customer service will improve real fast. In the age of network effects (Google, Facebook, Amazon, etc.), however, I leave it to the reader to decide if natural monopolies are as unlikely to thrive as they have been in the past, and whether anti-trust law should correspondingly evolve.
Symmetric information and rational preferences are mathematical constructs that AC need not assume. The AC would point out that you can’t phish for fools in a highly competitive market; or at least, it can’t be worse than our current system. Certainly, pockets of stupidity would thrive, but the system as a whole would be antifragile thanks to skin in the game.
Patents wouldn’t exist, but neither would trolls. Roads could be toll financed, and firefighters would be part of your insurance package. Private philanthropy would thrive thanks to the lack of governmental crowding out. Healthcare would be more affordable without bureaucratic inefficiencies, and the 2008 financial collapse wouldn’t have happened without central bank distortions and politically sanctioned moral hazard in the housing market.
But, in David Chalmer’s words, now comes the hard problem: externalities and military conflicts.
*Not to mention how inaccurately our school history books teach regarding the rise of the railroad, oil, and auto companies.
Free Not To ChooseAn externality occurs when a 3rd party benefits or loses from a transaction you and I engage in. I might be writing this paper for only Nick Bostrom and David Friedman (both of whom will likely never see it), but now you guys all get to benefit! On the other hand, I like cheap meat and oil as much as the next guy which would probably destroy the planet even faster under AC.
Not so fast, says the AC. As Milton Friedman pointed out in Free To Choose, the government itself creates externalities (smoke stacks), the negatives of which far outweigh the positives in the AC’s view. But a military conflict changes the dynamics of this calculation, as even David Friedman admits.
As a classic tragedy of the commons, if a military chooses to protect a certain area, everyone there benefits from the positive spillovers. Yet in an AC society, I am welcome to not join the Defense Forces of Denver. A free lunch. Everyone comes to the same conclusion, hence no one joins the military. And the damn Canadians invade us.
Nothing centralizes power like a military threat, especially a perceived one. Here’s where the fatal flaw in AC lies, in my view.
A Black Ball in the UrnNick Bostrom is one of the most unique philosophers alive today. He’s the kind of guy who would be wearing a tin hat if he was born a century earlier. Bostrom rose to notoriety after popularizing the surprisingly plausible simulation argument (more on that forthcoming) and has backing from the Elon Musks of the world thanks to his alarm bells regarding artificial general intelligence safety.
So when he again comes up with a terrifying and convincing thought experiment that could radically change the entire nature of society, your ears should prick. Bostrom asks us to imagine the horrendous: what if instead of being extremely difficult to procure, produce, and deploy, nuclear bombs could detonate by placing two pieces of glass in some sand and running an electrical current through them? There would be no school shooters; a single lunatic could turn Atlanta into ashes. Let us call such an individual The Joker.
Whoa, whoa, whoa, let’s not just panic, the Steven Pinkers of the world say. There’s no point in thinking like that little Johnny, clearly we know in hindsight that nuclear bombs are very hard to create. And there’s less violence than ever!*
But the point is we can’t and didn’t know that back in World War II. The race to create a nuclear bomb occurred after a couple of physicists ran the math, shat their pants, and, having no clue if it would be easy to make and the Nazis would beat them, spurred the most important scientific undertaking in human history through the Manhattan Project.
If nuclear bombs grew on trees and activated upon exposure to H2O, civilization would halt, likely never again advancing beyond rural communities, quite plausibly operating under AC that no proponent would support. Such a world, in Bostrom’s ever darkly poetic words, would have drawn a black ball from the urn.
*Sorry, I just finished reading Skin in the Game, and Nassim Taleb throws some heavy shade on Steven Pinker.
Since most of us don’t know what an urn is: Credit
Bostrom asks us to imagine that every time we develop a new technology, whether its GMOs that create super bugs, a virus with no cure, oil that destroys the planet, or AI that takes over the world and converts our brain into silicon to unify quantum mechanics and general relativity, we are drawing a ball from the technology urn.
Most technologies are white balls, those that will have mostly or entirely positive impacts. Gray balls are technologies that have both positive and negative impacts such as cheap oil. Black balls may or may not exist; these are balls that result in the destruction of any civilization that discovers them. This is usually because the technology is sufficiently destructive and sufficiently easy for a minority of the population to acquire and use against the rest of the population.
Given that by definition no one can possibly prove in advance that black balls do not exist until said technology is discovered/invented, Bostrom conservatively claims that the probability of a black ball existing could be non zero.
Vulnerable World Hypothesis (VHW): P(B exists) > 0
As an economist, I deal in expectations. Even if the P(B exists) == 0, the expectation could (and should) be non zero. Furthermore, self selection is no argument that P(B exists) = 0, since any population (such as our own) is alive until they draw a black ball. Therefore, today’s world exists in the following state:
Vulnerable World Expectation (VHE): E[P(B exists)] > 0
Surely, there must be a way to purchase civilization wide insurance such that E[P(B exists)] = 0. We need to, in fact, since a vulnerable world is in some sense that biggest externality of all. Existential threat is an irreversibility.*
Bostrom argues convincingly that the only way to get E[P(B exists)] = 0 is through terrifyingly Orwellian means. Namely, thanks to the “diverse motivations” of earthly people, we need at least one of the following to occur:
  • Restricting Technological Development
  • Preference Modification of Extremist Ideology (those willing to use tech simply Joker-style)
  • Extremely Effective Preventative Policing
  • Effective Global Governance
The first two are likely impossible under all structures, but certainly under AC. The last two sound innocuous until you look under the hood.
*I would argue that E[P(B exists)] > 0 is worse than P(B exists) > 0 because the expectation is what creates the race dynamics that leads to a winner take all scenario at the sacrifice of safety. This could be especially terrifying in a race for AGI, since AGI is simultaneously the solution to global governance and could be the black ball.
2084Let’s assume a black ball is drawn from the urn. Some mad scientist discovers a simple way to DNA sequence a virus without cure using a common 3D printer. She publishes her manifesto via Tor, using VPNs and public key encryption, with detailed instructions on how to recreate. How could we stop others from using it, or, even better, have prevented her from publishing it in the first place? Well, unfortunately, there is simply no way to do this without a global surveillance system.
Something or someone would need to watch what every single person and organization does at all times. Otherwise, a single Joker could reign chaos upon the world. Furthermore, we need global governance, in Bostrom’s words, to protect global commons and to “exit the semi-anarchic default condition.”
I know, I know. You’re begging me to tell you there’s a simple flaw missing in this reasoning. Surely a global surveillance and world order is overkill for a little thought experiment? Unfortunately, I don’t think there’s any other way to eliminate the Vulnerable World Expectation. That’s in today’s world and today’s governmental system. AC has no governmental system.
Anarchocapitalism in a Vulnerable ScenarioTo do some fake math, let’s assume a network interaction between people drawn from the following probability distribution.
Distribution(
Jokers, Steven Pinkers, Physicists, Economists, Philosophers, Evil Corp
)
The Steven Pinkers make up at least 95% of the population. These people are not worried at all about existential threat. Everyone else adds up to 5%, at ~1% each. Evil Corp is a misnomer. They really should be called Do Little Evil Corp. In other words, we don’t need to assume nefarious preferences on behalf of Evil Corp; some companies will out of self preservation believe VWE.
Let’s assume we are operating in a world governed by AC. Break up the world into t time intervals, from t0 to tN, where tN is the life of the universe.
At some point in time, tB, the physicists make some potentially black ball urney type discovery like the nuclear bomb. Then, say at tV, where tB≤tV, a Nick Bostrom philosopher type will discover the VWH. This simple discovery will result in VWE, since now many individuals could believe our world to be vulnerable.
In any random world, tV would probably usually be plus or minus a couple of millennia from now, depending on the level of technological sophistication and discoveries (nuclear, nanotechnology, biopharmaceuticals, etc.) of such a society. And to stroke my ego a little, let’s say tVMe is the time period where an economist realizes that the AC society they are living in might be unstable due to VWE. Usually, tVME > tV, since economists like myself are late to this whole “accurately describe reality” game.*
Here’s the kicker. Even if there is a flaw in Bostrom’s thinking (which there probably isn’t, the dude’s a savant), a non trivial portion of the population might begin fearing what would happen if another group of people discovered a black ball in the urn.
I’m certainly not assuming perfect rationality. They would conclude that something must be done. That something and only thing, per Bostrom’s thesis, is a global surveillance system and global government.
The Steven Pinkers of the world become irrelevant, due to the minority rule.** Since we are talking about the ultimate winner takes all situation, suddenly we have an incentive to create the damn thing, since if an opposing group of individuals beats us, the world is doomed.
The physicists blast full steam ahead,*** with some Jokers sprinkled throughout. The economists and philosophers ring the alarm bells. Finally, Evil Corp funds the physicists. Either a Joker wins and there was a black ball in the urn, or Evil Corp succeeds in quashing the future expectation that there is a black ball in the urn by establishing a global surveillance program with global governance.
Winner Take All Scenario
Stability in AC: Either[Joker → P(B exists) == 1, Evil → E[P(B exists)] == 0]
Evil just stands for any company in an AC society, be it OpenAI (Philosophers/Economists), Google (Self Interested), or Huawai (possibly nefarious). Point is there’s no government, so the deepest pockets will likely win.
Deeper point, either a Joker or group of Jokers will destroy the world, otherwise the system is unstable until some company quashes the expectation of a vulnerable world by establishing a world government and surveillance system.
So, back to my original argument that AC would be neither libertarian nor stable, virtually no libertarian would support such a surveillance program. The risk of misuse would be much too high. But in an AC world with no pesky governments, corporation Hooli, led by the egomaniacal yet civic minded Howard Roark, would take it upon itself to establish a world order.
In conclusion, this world would certainly not be libertarian. It could possibly reach stability after removing VWE, but would it conceivably remain AC? Plato’s forms are relevant here. Is a society controlled by a small group of executives running corporation(s) maintaining global surveillance to protect the world order really that different from a centralized government (or our current world for that matter)?
* tVMe = 1939
**I really have nothing against Steven Pinker. I actually like his optimism!
***In WWII, it was the physicists. WWIII might just come down to the computer scientists. AKA Evil Corp = Google and the black ball is AGI 😮

Saturday, January 19, 2019

Redistricting Rules (and) Republicans


Control of Redistricting Process
by Number of Congressional Seats

"Other" includes states with only 1 congressional seat, independent redistricting commissions, etc. 

Introduction (10-15 Min Read)
Redistricting is as interesting as its import, bringing up fundamental issues in political science, economics, statistics, and social contract theory, as well as illuminating imperfections in the US Constitution. In fact, the phrase 'gerrymandering', referring to the negative process of politicians abusing redistricting laws, arose almost as soon as our Constitution was ratified. 

While we've had an intuitive sense of when and how politicians have exploited redistricting for at least two centuries, its only been in the past couple of decades that we've had the precise mathematical tools and computer resources to detect gerrymandering in a rigorous and statistical fashion. The implications are nothing short of a computational rewrite of the Constitution.

Republicans Rule Redistricting
After strong wins in the 2010 midterms, Republicans had "complete control" of 21 states' redistricting processes, while Democrats only had comparable control for 5 states. This led to GOP power of 210 congressional seats' redistricting, compared to a paltry 44 seats for the Democrats. You can see the magnitude by comparing the difference between the percentage of seats allocated with the percentage of votes per party, what might be called the proportionality gapOn average in 2016, a 1% increase in vote share led to a 2% increase in the number of seats for a given party.

This is calculated as the percentage of seats minus percentage of votes for Democrats in 2010 by state. This is influenced by many states where no Republicans or Democrats win, i.e. the aggregate percentage difference does not correspond to aggregate seat differences. Nonetheless, it is clear Republicans have significantly more states where they benefit from our current system. Data collected from ProPublica.


Undoubtedly, changing districts to benefit incumbents and partisans, the primary way politicians pick voters, gave Republicans an edge in the 2018 election. According to one estimate, partisan gerrymandering could have cost Democrats 10-15 seats or more, probably preventing an otherwise blue bloodbath. As one of the more egregious, and unconstitutional, examples, North Carolina voted 49.8% for Trump vs 46.2% for Clinton, yet Republicans control 10 of 13 congressional seats!


North Carolina Congressional Districts


Redistricting Rules Republicans (and Democrats) 
But insofar as the rules put in place for redistricting are so easy to game, can we really be surprised politicians leverage them in their favor? In most states, redrawing congressional districts is a legislative process that occurs every 10 years. If one party has majority control of their state's government, then it is fairly easy to pass laws to the benefit of that party; in this case, biased redistricting laws. Call it incumbency insurance.

Political Incentives


In fact, it would be foolish for self-interested politicians to ignore these short term incentives while allowing their opposing party to take advantage of them. This is why in 1980 the Republicans sounded like today's Democrats, complaining about the unfairness of the redistricting process. Historically, Democrats got the upper hand in redistricting procedures (see the chart below), although this has started to change due to geographical clustering of parties.

Brookings


Bonus for the Losers
According to one paper that studies the dynamics of geographical clustering and who benefits in a winner-takes-all system,

"Republicans benefit from the loser’s bonus in most of the large states of the Northeast and West Coast, while the Democrats benefit elsewhere. On balance, the loser’s bonus is beneficial to the Republicans, and the size of U.S. Congressional districts relative to urban clusters of Democrats is quite well suited for the representation of Republicans in Congress."

From the Loser's Bonus- You can see that geography makes a big difference in who benefits. The authors argue that the degree of bonus is correlated with the the concentration of Democrats in cities. 

Longer term, however, pursuing gerrymandering could backfire against Republicans. While geographic trends favor Republicans, demographic trends over the next 10-25 years heavily favor Democrats. If redistricting amplifies the ruling party's lead by providing disproportional voting rights, then if the redistricting cycle reverses from demographic pressure, Democrats could solidify their power for decades to come.

This shows how redistricting favors both parties at different times and places. Sometimes Republicans benefit. Where? 2016. Somewhere Democrats benefit. When? Texas. Sometimes Democrats benefit. Where? 1961. Somewhere Republicans benefit. When? Where? What? Ugh, who cares what the politicians want? It's time to take matters into our own hands!

Expecting politicians to exhibit strategic long term thinking is like economists assuming all humans behave rationally. One might hope a fairer policy would benefit both parties overall, but if not, public policy is for the people not the parties.

Redistricting Rules
There are really only 2 redistricting rules that the supreme court has decreed unconstitutional: racial redistricting and lack of equal population per district. An important caveat is that partisan gerrymandering is often okay, and since racial and partisan redistricting are highly correlated, most redistricting efforts are de facto legal and difficult to challenge in court.




Many states add the desirable constraints requiring boundaries to be continuous (or not arbitrarily splitting) and compact (not too unusual of a shape), but this is usually not a precious definition, And mathematically speaking, there is a virtually infinite number of ways to break up the geometry of state districts. Even with the main constraints being equal population per district and continuity, politicians can fairly easily pick the most aggrandizing district boundaries. How do they do this?


Wikipedia


Packing the Crackers
Imagine a state with 5 districts, where 40% of citizens vote Republican and 60% vote Democrat. Packing is what happens in the top right rectangle above, where one party's voters are concentrated or 'packed' into a couple of districts, limiting their impact and leading to 3 out of 5 districts going to the Republicans.

Cracking, on the other hand, involves splitting and diffusing a party's voters such as the top left rectangle above, leading to the theoretical possibility that Republicans get 0 seats even after receiving 40% of the vote. Either way, the goal is to manipulate district boundaries to the disproportionate benefit of the party in control.

Note, this toy example succeeds in showing gerrymandering under the assumptions of equal population per district and continuity, but these concepts extend to many, if not most, US states.




Mind the Efficiency Gap
Update: Thanks to a comment, I have provided a more direct and intuitive definition of the Efficiency Gap.

How can we detect if partisan gerrymandering has occurred? It might be tempting to simply compare the percentage of votes with the percentage of seats- aka the proportionality of the redistricting process. However, from a legal perspective what matters more is partisan symmetry. As the New York Times reports:

‘‘... the Supreme Court has rejected proportional representation, which the Constitution doesn’t provide for, as a measure of mandating fairness in elections. Instead of dictating that a party with 46 percent of the vote takes 46 percent of the seats, symmetry means that if Republicans win 60 percent of the seats with 46 percent of the vote in one election, then Democrats should be able to win 60 percent of the seats with roughly the same percentage of the vote in another election."

This leads to a concept called the efficiency gap based on a related concept of wasted votes. A wasted vote is any vote that is not for an elected candidate or any vote in excess of 50% for that elected candidate, i.e. a vote that didn't help the winning candidate win. Let W(R) be the wasted votes for Republicans, W(D) be the wasted votes for Democrats, and T be the total votes cast in an election, then the efficiency gap EG can be defined as follows:

EG = [W(D) - W(R)] / T, ranging from 0.0 to 0.5, which simplifies to:

EG = [ D(S) % - 50% ] - 2* [ D(V) % - 50% ], where D(S) is the number of seats allocated to Democrats, and D(V) is the number of votes statewide to Democrats.

In words, the efficiency gap is the difference between the amount of seats won compared with the amount of votes allocated statewide, very similar to a measure of proportional representation. For example, in North Carolina, Democrats won 3/13 = 23% of seats and ~47% of statewide votes, leading to EG = (23% -50%) - 2*(47% -50%) = -27% + 6% = -21%. Any EG (whose absolute value is) more than 8% is considered egregious.

Here's the efficiency gap measure per state where you can see North Carolina and Pennsylvania rank highest:

Azavea

The problem with the efficiency gap is that it doesn't factor in the unintentional geographical clustering of parties. Democrats have been populating urban cities while Republicans have been moving out to the suburbs and the farms. This means that even with no intentional partisan gerrymandering, there would still be a redistricting benefit on average to Republicans, so that Democrats can expect to win less than 50% of the seats even if they win 50% of the votes.

As such, the efficiency gap can lead to many false positives or false negatives by trying to summarize extremely complicated ("multidimensional") geographic and political representation into a single number. This muddles things a bit and gives ammunition to Republicans arguing that the efficiency gap shouldn't be used in court. If Democrats naturally self sort into cities, our hypothetical Republican friend argues, Republicans aren't being partisan hacks; they must gerrymander to protect themselves against geographic unfairness!

Court cases have rarely been settled solely based on the efficiency gap; instead, it is part of an overall argument put forward by those challenging gerrymandered districts. Is there hope for a better way?

Back to the reDrawing Board
As we can see, the lack of mathematical rigor has made arguments for and against gerrymandering literally go on for centuries. Perhaps we should start with some first principles.

1. Should we just give reign to independent commissions?

Probably, but we still need to give them a framework to abide by. Iowa and Missouri offer admirable models; Iowa for its long history and Missouri for its use of a statistical model based on the efficiency gap that was approved in 2018. The idea of following a mathematical formula can be attractive to both the right and the left. Simple rules reduce the ability for politicians to take advantage of a system while increasing the transparency of the process.

2.  Is there a non-partisan argument against competition?

FiveThirtyEight has a great tool for showing redistricting simulations, including what states would look like if they maximized the number of seats where either a Republican or Democrat could win (i.e. the competitiveness of each seat). While neither Democrats nor Republicans will probably like that approach in safe districts, this approach would be best for a democratic system aiming to better represent the views of its citizens, as well as reducing politicians' complacency and incumbency. Missouri's recent amendment requires partisan fairness first and competitiveness second. 

3. Is there a non-partisan argument against proportional representation?

The issue of proportional representation is slightly more complex. As mentioned, the Constitution doesn't explicitly require the number of seats allocated to be proportional with the number of votes; however, intuitively, it seems like proportional representation is the fairest and least biased approach. This might even give 3rd parties a chance to compete with the 2 party duopoly, allowing for better representation of diverse view points. 

Republicans might counter saying that they are geographically disadvantaged and deserve disproportional representation, but the Constitution accounts for geographic representation by giving every state 2 senators, no matter how small. And proportional representation doesn't mean Republicans get no votes; on the contrary it ensures Republicans would always get some representation assuming they get more than 0 votes. 

4. Do we really need compact districts?
You tell me which picture looks more natural and less likely to be abused by politicians. 

https://bdistricting.com/2010/PA_Congress/

A Statistical Approach
If the efficiency gap isn't entirely appropriate, is there a better way of detecting partisan redistricting? A couple of Carnegie Mellon mathematicians seem to think so. "The task then is to evaluate whether a districting not only favors a given political party, but does so to a degree that is atypical for the particular political geography of the state." Their mathematically complex but intuitively simple approach can be outlined as follows:

Define valid districts by equal population, continuity, and compactness. Compare current districts per state by all total valid districts, what is called the total "space" of valid districts in statistical terms. Since the total space is very large, most valid districts will not result from partisanship. Only statistically unusual districts will probably be the result of intentional gerrymandering.

The difficulty is that the total space of districts isn't just very large; it's insanely large, so yuge you couldn't in practice exhaustively search all districts even with the most advanced super computers available. But human ingenuity doesn't stop where search spaces grow exponentially

Instead, start with the current districts. Apply millions of small random changes known as "Markov Chains." If your current district appears "among the worst ε fraction of districtings observed in the Markov sequence, and ε is very small, than this would seem to indicate that X0 [your current district] is somehow a very carefully chosen member." Indeed, they prove you would need to run approximately 1 trillion simulations before you get Pennsylvania's current districts! Virtually, statistically, impossible.

Future Projects
Projects such as PublicMapping.Org introduce transparency in the redistricting process by allowing you to create your own districts for any given state. BDistricting.com shows what each state might look like without gerrymandering. Additionally, FiveThirtyEight has some interactive maps that allow you to see various scenarios such as maximizing the competitiveness of races, minimizing the efficiency gap, or maximizing one party's gain.


FiveThirtyEight

It would be valuable for historical analysis, as well as understanding the dynamics, instability, and polarization introduced through the redistricting process, to create a comprehensive time series map from the founding of the US to now of the redistricting geographic boundaries, voting records, efficiency gaps, and other measures across each state.

Additionally, running the aforementioned statistical approach on not only current but historical data sets could further refine this line of thinking. Open sourcing these data and algorithms to the public would provide insight and accelerate research into what has no doubt been one of the greatest distortions of voter intentions in US history.


Saturday, December 1, 2018

Learn Python and APIs with Open Weather Map in 5 Mins

My motivation for this post is to show how easy it is to start programming. Too many people are mystified by what programmers do, when in reality anyone can learn a little programming and automate simple tasks in their lives.

Here I use Open Weather Map to get weather data for a list of US cities. I use Python since it is one of the most readable and easiest languages to get started with, and I use the library 'requests' to simplify getting data from an API. The whole code is about 20 lines including comments, and you can run it yourself here without downloading anything! Here is the full code if you just want to jump in:





Topics: Python, APIs, HTTP Requests, Arrays, For Loops, Conditionals, and More!
Python
I love Python for its simplicity and readability, which helps when I need to quickly put together a prototype. Many other languages, like Java, C++, Node.js, etc. are more verbose and so can often take longer to write and understand. While these other languages have their own benefits, Python is very powerful and a great starting point for non-developers. Whether you want to do data analysis, machine learning, or web backends, Python is a great tool.



APIs
API stands for Application Programming Interface, which is just nerd talk for "a simple way to communicate with a server." Its the building block or backbone for most of modern programming. Want to add Google Maps to your site? Use Google's API. Want to build a Bitcoin wallet app? Try Blockchain's API. Want to build an automated email campaign? Check out Sendgrid's API. Want to build an object tracking computer vision app? Check out OpenCV. Want to build a machine learning app? Try Tensorflow's API. Want to creep on your friends? Just use Facebook's API.

The documentation is usually all you need.

Want to get stock price data? Try Intrinio's API. Want to track the number of clicks a link gets? Check out Bit.ly's API. Want to make a bid on eBay within seconds? Check out their API. I could go on and on and on, but I'm just as annoyed as you are.



HTTP Requests
Most APIs require making an HTTP request over the internet. In Python, you can use a simple library called requests. A library is just someone else's code that makes your life simpler. Instead of having to write the code yourself, someone else took hundreds of lines of code and allow you to only need to run one line. This is part of why it is infinitely easier to code in 2018 than in 1998. At the top of your code in Python you "import" libraries that you plan to use. Many APIs return the data in JSON format, which looks like this: "name":"Pepito""age":30"car":null }

In our case, the HTTP Link we want to use is Open Weather Map's. The base link is http://api.openweathermap.org/data/2.5/ We can add what are called parameters to specify what kind of data we want to request. Open Weather Map's API has a ton of options. We will use 'weather' to get the current weather data, as opposed to 'forecast' for the 5 hour prediction.

API Key Security
For every API you use, you will need an API key, which is basically your unique password. In general, you should never share your API key with anyone. Once a developer accidentally shared my Google Cloud Key on a public Github Repository, and someone proceeded to use my key for mining cryptocurrency. Fortunately, Google detected and reimbursed my mistake within 24 hours; otherwise I would have been charged $300 for cloud usage. Accidentally sharing API keys is also how a hacker store 50 million user's data from Uber! Additionally, you should try not to store API keys in plain text, but instead use environment variables. That's beyond the scope of this post, but if you are working in an security intensive application, make sure to read a lot more and consult with experts. In this case, I am using a free API key that limits 60 requests per second, and I am trying to avoid you needing to create an account, so hopefully no one abuses this key. If they do though, I will have to remove my key and replace it with "putYourAPIKeyHere."

Logic: Variables, Arrays, For Loops, and Conditionals
If you just learn these simple concepts, you will be well on the way to learning programming. A variable allows you to store the same word, integer, or other information to be used later in your program. For example, we use weather = r['weather'] to store the responses' weather attribute and later print it out. Printing is what spits stuff out in the console for you to read. We also use variables to adapt the HTTP Link we want to call

httpLink = 'http://api.openweathermap.org/data/2.5/'+ parameter+'?q=' + city +',us&appid=' + owm_api_key

Arrays are the basically multiple variables- they allow you to store infinite information in any format. We use cities = ['New York', 'Denver', 'Atlanta'] to store an array with the cities we want to analyze. This leads to the concept of 'for loops.' For loops are used if we want to iterate (or go one by one) through an array in order to execute a specific piece of logic for each input. In our case, we want to make a weather request for each city in our array. Finally, just to show the concept of conditionals, or if statements, I add a print statement if city == 'Denver'

From each of these concepts, you can start to build apps. Web APIs allow you to build off of other companies' libraries, Python makes it easy to start programming, and learning a little logic guides your intuition as a programmer. No doubt, there is much more to learn to be a great programmer, but this just shows that in a very short period of time you can learn how to program and build off existing concepts.