alex / nyt-2020-election-scraper

Home Page:https://alex.github.io/nyt-2020-election-scraper/battleground-state-changes.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hurdle is off when greater than 100%

DryHeatAz opened this issue · comments

(NOTE: This is not about the previous issues with calculating the hurdle; it's about an edge case.)

Pennsylvania currently shows Biden ahead by 54,273 with 7,914 votes remaining to be counted. Hurdle is 397.3%.

But if Trump got 397.3% of the remaining vote Biden's lead would still be over 20,000 votes. Trump needs 685.8%.

This is a quibble, but it might be worthwhile to figure out why this is happening.

This is a fantastic project and I hope it is available in 2024. It's the clearest way to see what is really happening.

DryHeatAz is exactly right.
The "hurdle" calculation below from the repository is only valid when  votes_remaining_relevant > vote_diff.

The reason is that the hurdle percentage calculation assumes that
the person behind will get the hurdle percentage and that the person ahead will still get 1-hurdle percentage,
even when hurdle percentage is > 100%.

    votes_remaining_relevant = votes_remaining * latest_relevant_proportion
    hurdle = (vote_diff + votes_remaining_relevant) / (2 * votes_remaining_relevant) if votes_remaining_relevant > 0 else 0

Lines 349-350 in "print-battleground-state-changes" (a python file)
https://github.com/alex/nyt-2020-election-scraper/blob/master/print-battleground-state-changes

As long as we are showing hurdle rates > 100%, the calculation probably should be:

    votes_remaining_relevant = votes_remaining * latest_relevant_proportion
    if vote_diff < votes_remaining_relevant:
        hurdle = (vote_diff + votes_remaining_relevant) / (2 * votes_remaining_relevant) if votes_remaining_relevant > 0 else 0
    else: # assume no change in votes for the leader, all remaining go to the person behind
        hurdle = (vote_diff/votes_remaining_relevant) if votes_remaining_relevant > 0 else 0