Skip to content

Instantly share code, notes, and snippets.

@JulianNorton
Created September 1, 2017 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JulianNorton/51ddf755ada542b0f89981318f9cf870 to your computer and use it in GitHub Desktop.
Save JulianNorton/51ddf755ada542b0f89981318f9cf870 to your computer and use it in GitHub Desktop.
170901 Riddler Express
'''
https://fivethirtyeight.com/features/is-your-friend-full-of-it/
Riddler Express
From Shaun Raviv, a tall tale on the basketball court:
You’re hanging out with some friends, shooting the breeze and talking sports.
One of them brags to the group that he once made 17 free throws in a row after years of not having touched a basketball.
You think the claim sounds unlikely, but plausible. Another friend scoffs, thinking it completely impossible.
Let’s give your bragging friend the benefit of the doubt and say he’s a 70-percent free-throw shooter.
So, who’s right? What is the number of free throws that a 70-percent shooter would be expected to take
before having a streak of 17 makes in a row?
And what if his accuracy was a bit worse?
'''
def calculate_bs(throw_chance, number_of_throws):
chance_of_happening = throw_chance**number_of_throws
typical_throws_needed = 1 / chance_of_happening
return typical_throws_needed
generous_throw_chance = .7
bad_throw_chance = .35
number_of_throws = 17
# 70% throw chance
print(calculate_bs(generous_throw_chance, number_of_throws))
# 429.866… tries Friend COULD be right, but unlikely.
# 35% throw chance
print(calculate_bs(bad_throw_chance, number_of_throws))
# 56,343,425 tries. Friend is full of BS or is rediculously lucky.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment