""" Homework 7
-- Due Sunday, March 20th 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 nba_winners(n):
''' According to Nate Silver, the top teams in the NBA
playoffs had the following ELO scores as March 1st:
West East
Warriors: 1819 Cavaliers: 1654
Spurs: 1788 Raptors: 1610
Clippers: 1647 Celtics: 1596
Thunder: 1636 Heat: 1539
TrailBlazers: 1600 Hawks: 1534
Grizzlies: 1542 Hornets: 1532
Rockets: 1523 Pistons: 1521
Mavericks: 1521 Pacers: 1507
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)
Assume the playoffs start today and the teams are ordered as above.
The format of the playoffs is here where each series is best-of-7:
https://en.wikipedia.org/wiki/NBA_playoffs#Format
Run n simulations and return a dictionary with the probability
of each team winning.
'''
pass
def spurs(n):
'''
Using the function above (with argument n), what is the probability
that the Spurs win given that the Warriors lose?
'''
pass
def random_nba_winners(n):
'''
Run n of the following experiment and return the probability that
the Warriors win the tournament:
Randomly generate 14 Western and 15 Eastern teams with ELOs from a
normal distribution with mean of 1500 and std. deviation of 100 and put
the top teams into playoff slots in order, with the Warriors being first.
(Use any team names you like.)
Run the playoffs with these teams.
Return the pair Pr(Warriors | ELO_1750), Pr(Warriors | not ELO_1750)
where "Warriors" means the Warriors win and ELO_1750 means the best
team has an ELO greater than 1750.
'''
pass
def elo_pred(n):
'''
There's a 16.5% chance that your generated 29 teams has some team
with ELO > 1750. (Feel free to check this.)
Using the function above (with argument n) what's the probability
that some team has ELO > 1750, given that the Warriors lose?
Hint: Use Bayes' Theorem
'''
pass
def PAC_alien_detector(log, epsilon, delta):
''' All alien spacecraft have certain properties in common.
For example, they may all be silver, disk-shaped and flashing.
(No non-alien ships will have all these properties.)
Your job is to discover with probability 1 - delta a set of
properties that correctly identifies 1 - epsilon fraction of aliens.
Conveniently, you have log (implemented as an infinite generator)
of all UFO sightings from 1900 until the end of time.
Every entry in the log is a dictionary from n properties to
true/false, with the keyword "alien" identifying whether it's an
alien.
Some sample entries that correspond to the example above:
e1 = {"alien": True, "disk":True, "cold":False, "silver":True,
"flashing":True, "heavy":True, "antennae":False}
e2 = {"alien": False, "disk":True, "cold":True, "silver":False,
"flashing":True, "heavy"=True, "antennae":True}
Hint: The running time should depend on epsilon, delta and a
variable for you to determine. Play around with different options.
Hint: Look up PAC conjunction learning
'''
pass
def UFO_log():
''' Write a UFO log.
It should generate UFOs with 20 properties, each randomly
assigned to True or False according to some distribution(s).
Label all silver, disk-shaped and flashing ones "alien".
Use this to test your detector above.
'''
pass