<commit_before>---
title: Dizzying Democratic delegate... math
description: A short rant about Democratic delegates and a calculator tool to go along with it.
---

Elections in this country are weird. So many of our elections aren't measured in the number of people who vote for a candidate but instead are measured in how many points a campaign can score.

The most famous example of this is the Electoral College. But we're well into the Democratic presidential primary, and it has its own set of points: "delegates".

The goal for each campaign is still to get the most votes possible but the winner isn't as simple as that. The winner is the person who can get to 1,991 delegates, which would give them 50%+ at the Democratic National Convention later this year in Wisconsin. Having a majority of delegates means the candidate gets the party's nomination.

Delegates are _mostly_ based on vote counts, but they are themselves much smaller numbers. And there are some sharp edges to the delegate math, such as the fact that any candidate with less than 15% gets exactly **0 delegates**.

So small flucations within an election can matter for the eventual delegate count. I wanted to see the algorithim in action so I made a small tool to determine how delegates are awarded within a single jurisdiction. Delegates are awarded at multiple jurisdications, such as the state level and generally the Congressional district level, though depends on the state.

<style>
  button {
    background-color: gold;
    border-color: transparent;
    border-style: solid;
    border-width: 3px;
    color: black;
    cursor: pointer;
    display: block;
    font-family: serif;
    font-size: 1.1rem;
    margin: 0 auto;
    text-decoration: none;
  }

  button:hover {
    background-color: transparent;
    border: 3px dashed gold;
  }

  details {
    background-color: #ebebeb;
    margin-bottom: 1rem;
    padding: .4rem;
  }

  details p {
    margin-bottom: 1rem;
  }

  input {
    font-family: monospace;
    font-size: 1.1rem;
    width: 50%;
  }

  table {
    border-collapse: collapse;
    width: 100%;
  }

  th {
    display: none;
    text-align: left;
    width: 100%;
  }

  td {
    border-bottom: 2px dashed #ebebeb;
    display: flex;
    font-size: .9rem;
    justify-content: space-between;
    padding-left: .2rem;
    padding-right: .2rem;
    padding-top: .2rem;
    padding-bottom: .2rem;
  }

  td:last-child {
    border-bottom: 2px solid black;
  }

  td::before {
    content: attr(data-column);
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    padding-top: .2rem;
  }

  table input {
    background: transparent;
    border: none;
    text-align: right;
    width: 75%;
  }

  @media screen and (min-width: 1000px) {
    th {
      display: table-cell;
      width: 20%;
    }

    td::before {
      display: none;
    }

    td {
      display: table-cell;
      font-size: 1rem;
    }

    td:last-child {
      border-bottom: 2px dashed #ebebeb;
    }

    table input {
      text-align: left;
      width: 100%;
    }
  }
</style>

We're starting with an assumption that each candidate got 100 votes and that there are 50 delegates available in the jurisdiction. You can, of course, change any of those assumptions below. If you change any of the fields below, the delegate count will update.

<details>
<summary>If you're done playing around or looking for a place to start, expand this section to see something I find interesting.</summary>

<p>Let's assume that everybody's doing reasonably well and getting 20,000 votes. Except one candidate is clearly leading. Imagine that Bloomberg bought enough ad space and paid enough influencers to garner 33,333 votes.</p>

<button class="db p1" id="load-bloomberg-scenario">Make it so!</button>

<p>Well, that's all well and good and everybody's getting some delegates, though Mike is winning in the vote count and therefore is also winning in the delegate race. He gets 12 while everybody else is getting 8.</p>

<p>But what if he gets just one more vote? What if one of his supporters got their neighbor to come with them to the polls and cast that 33,334th vote for El Bloombito?</p>

<button class="db p1" id="bloomberg-scenario-give-vote">Give Bloomberg one more vote</button>

<p>That one vote throws everybody else below the 15% threshold and all the delegates go to a single candidate. In the calculator, Bloomberg's percentage doesn't change with just one vote because of rounding.</p>

<p>Now, of course there's going to be a point that triggers the threshold. This isn't to argue the merits of a 15% threshold, just showing one consequential effect of it.</p>
</details>

<div class="flex items-center justify-between mb2 sm-col-12 lg-col-6">
  <label class="bold" for="delegates">Delegates</label>
  <input id="delegates" type="number" min="0" value="50">
</div>

<div id="delegate-calculator"></div><commit_msg>Small edits to dem delegate math<commit_after>---
title: Dizzying Democratic delegate... math
description: A short rant about Democratic delegates and a calculator tool to go along with it.
---

Elections in the U.S. are weird. So many them aren't measured in the number of people who vote for a candidate but instead are measured in how many points a campaign can score.

The most famous example of this is the Electoral College. But we're well into the Democratic presidential primary, and it has its own set of points: "delegates".

The goal for each campaign is still to get the most votes possible but the winner isn't as simple as that. The winner is the person who can get to 1,991 delegates, which would give them 50%+ at the Democratic National Convention later this year in Wisconsin. Having a majority of delegates means the candidate gets the party's nomination.

Delegates are _mostly_ based on vote counts, but there are some sharp edges to the delegate math. For example any candidate with less than 15% gets **0 delegates**.

So small fluctuations within an election can matter for the eventual delegate count. I wanted to see the allocation algorithim in action so I made a small tool to determine how delegates are awarded within a single jurisdiction. Delegates are awarded at multiple jurisdications, such as the state level and generally the Congressional district level, though depends on the state.

<style>
  button {
    background-color: gold;
    border-color: transparent;
    border-style: solid;
    border-width: 3px;
    color: black;
    cursor: pointer;
    display: block;
    font-family: serif;
    font-size: 1.1rem;
    margin: 0 auto;
    text-decoration: none;
  }

  button:hover {
    background-color: transparent;
    border: 3px dashed gold;
  }

  details {
    background-color: #ebebeb;
    margin-bottom: 1rem;
    padding: .4rem;
  }

  details p {
    margin-bottom: 1rem;
  }

  input {
    font-family: monospace;
    font-size: 1.1rem;
    width: 50%;
  }

  table {
    border-collapse: collapse;
    width: 100%;
  }

  th {
    display: none;
    text-align: left;
    width: 100%;
  }

  td {
    border-bottom: 2px dashed #ebebeb;
    display: flex;
    font-size: .9rem;
    justify-content: space-between;
    padding-left: .2rem;
    padding-right: .2rem;
    padding-top: .2rem;
    padding-bottom: .2rem;
  }

  td:last-child {
    border-bottom: 2px solid black;
  }

  td::before {
    content: attr(data-column);
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    padding-top: .2rem;
  }

  table input {
    background: transparent;
    border: none;
    text-align: right;
    width: 75%;
  }

  @media screen and (min-width: 1000px) {
    th {
      display: table-cell;
      width: 20%;
    }

    td::before {
      display: none;
    }

    td {
      display: table-cell;
      font-size: 1rem;
    }

    td:last-child {
      border-bottom: 2px dashed #ebebeb;
    }

    table input {
      text-align: left;
      width: 100%;
    }
  }
</style>

We're starting with an assumption that each candidate got 100 votes and that there are 50 delegates available in the jurisdiction. You can change either of those assumptions below. When you change any of the fields below, the delegate count will update.

<details>
<summary>If you're done playing around or looking for a place to start, expand this section to see something I find interesting.</summary>

<p>Let's assume that everybody's doing reasonably well and getting 20,000 votes. Except one candidate is clearly leading. Imagine that Bloomberg bought enough ad space and paid enough influencers to garner 33,333 votes.</p>

<button class="db p1" id="load-bloomberg-scenario">Make it so!</button>

<p>Well, that's all well and good and everybody's getting some delegates, though Mike is winning in the vote count and therefore is also winning in the delegate race. He gets 12 while everybody else is getting 8.</p>

<p>But what if he gets just one more vote? What if one of his supporters got their neighbor to come with them to the polls and cast that 33,334th vote for El Bloombito?</p>

<button class="db p1" id="bloomberg-scenario-give-vote">Give Bloomberg one more vote</button>

<p>That one vote throws everybody else below the 15% threshold and all the delegates go to a single candidate. In the calculator, Bloomberg's percentage doesn't change with just one vote because of rounding.</p>

<p>Now, of course there's going to be a point that triggers the threshold. This isn't to argue the merits of a 15% threshold, just showing one consequential effect of it.</p>
</details>

<div class="flex items-center justify-between mb2 sm-col-12 lg-col-6">
  <label class="bold" for="delegates">Delegates</label>
  <input id="delegates" type="number" min="0" value="50">
</div>

<div id="delegate-calculator"></div>
{'fraction_non_alphanumeric': 0.08340990301174069, 'fraction_numerical': 0.01796835119959163, 'mean_word_length': 3.3537777777777777, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1371809', 'n_tokens_mistral': 2994, 'n_tokens_neox': 2747, 'n_words': 1274}