Skip to content

Instantly share code, notes, and snippets.

@arseniyturin
Created July 30, 2021 20:07
Show Gist options
  • Save arseniyturin/e907ac2c846c80219b5e1f0471b81020 to your computer and use it in GitHub Desktop.
Save arseniyturin/e907ac2c846c80219b5e1f0471b81020 to your computer and use it in GitHub Desktop.
Unfair coin
'''
100 coins / 99 fair + 1 unfair (both heads)
pick one
flip 10 times = 10 heads
what is the probability that this coin is unfair?
P(A) * P(B|A)
P(A|B) = ----------------
P(B)
P(A) = 0.01 - chances of unfair
P(B|A) = 1 - probability of success given it unfair
P(B) = (0.99 * 0.5^10) + (0.01 * 1^10) - total success outcomes (fair or unfair)
P(A|B) = 0.01 / 0.01096 = 0.912
Answer: there is 91% chance that the coin is unfair
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment