""" Homework 7
-- Due Sunday, Oct. 25th at 23:59
-- Always write the final code yourself
-- Never use a library function that solves the problem
-- If you collaborated with a peer, mention them
-- Cite any websites you referenced
-- Use the PEP-8 checker for full style points:
https://pypi.python.org/pypi/pep8
"""
def probably_approximately_fair(coin, epsilon):
''' Takes in a coin (a function that returns True (heads) or False (tails)
with some probability) and an epsilon between 0 and 1.
Returns True with 99%+ probability if the coin is fair.
Returns False with 99%+ probability if the coin is epsilon away from fair.
(For example, if the coin returns heads 40% of the time, it is 0.1 away
from fair.)
Otherwise, can return True or False. '''
pass
def mlb_winners(n):
''' According to Nate Silver, the teams in the Major League Baseball
playoffs had the following ELO scores as of the season end on October 4th:
Blue Jays - 1572
Cubs - 1553
Cardinals - 1549
Royals - 1543
Dodgers - 1535
Rangers - 1526
Mets - 1523
Astros - 1518
We can translate ELO into a probability of winning via the following
formula:
Pr(A_beats_B) = 1 / (10^(-(ELO_A - ELO_B)/400) + 1)
The playoffs are (as of Oct 7) played as follows:
Royals Cardinals
Astros Cubs
|----------------WS--------------|
Blue Jays Dodgers
Rangers Mets
where the first series is best-of-five, and the latter two are
best-of-seven.
For example the Blue Jays might win 3-1 over the Rangers,
then 4-3 over the Royals and finally lose to the Mets 2-4.
Run n simulations to print out the probability of each team
winning the World Series, in alphabetical order.
'''
pass
def unexpected_victory(n):
''' Same as above, but for each team calculate the probability of losing
the first game AND winning the world series.
(Note that these are NOT independent events.) '''
pass
'''' Answer all of the following questions using the results from preceding
questions (no more simulations). '''
def come_back(pr_win, pr_lose_win):
''' For each team, what is probability that it wins the World Series
GIVEN that it lost the first game? '''
pass
def keep_winning(pr_win, pr_lose_win):
''' For each team, what is probability that it wins the World Series
GIVEN that it won the first game? '''
pass
def won_first(pr_win, pr_lose_win):
''' Let's flip the previous question:
For each team, GIVEN that it won the World Series, what is the probability
that it won its first game?
'''
pass
def all_around_victor(pr_win, pr_lose_win):
''' What is the probability that some team that won its first game
won the world series? '''
pass