November 15, 2019
For today
Read Kuhn, Objectivity, Value Judgment and Theory Choice and prepare to discuss the reading questions.
To prepare for the quiz, read about the NK Model.
Work on your project, and turn in a notebook running on Binder or Colab.
Today
Quiz
Kuhn
Project
For next time:
Work on Notebook 11 (due next Friday)
Work on your project.
Optional reading: The Economist, The new genetics: Modern genetics will improve health and usher in “designer” children
Next week: Bayesian Statistics Made Easy
No preparation, just class time.
Why Bayes?
1) You might remember on the first day, I identified as one of the trends in 20th-21st Century science a transition from Aristotelean/binary logic to many-valued logic. Well, Bayesian reasoning is an example.
2) Bayesian reasoning is at least a good way of thinking and arguably a requirement for rational thought. So I thought you might like to know.
Classify the following functions.
Assume the length of t1 is n and the length of t2 is m.
#1
def list_intersection(t1, t2):
res = []
for x in t1:
if x in t2:
res.append(x)
return res
#2
def list_intersection(t1, t2):
res = []
for x in t1:
for y in t2:
if x == y:
res.append(x)
return res
#3
def list_intersection(t1, t2):
res = []
if len(t1) > len(t2):
for x in t1:
if x in t2:
res.append(x)
else:
for x in t2:
if x in t1:
res.append(x)
return res
#4
def list_intersection(t1, t2):
res = []
t2.sort()
for x in t1:
if bisect_in(x, t2):
res.append(x)
return res
#5
from bisect import bisect_left
def bisect_in(x, t):
"""Uses bisect to check if x is in t.
x: element to find
t: sorted list
Returns: boolean
"""
i = bisect_left(t, x)
return i != len(t) and t[i] == x
#6
def list_intersection(t1, t2):
res = []
for x in t1:
t2.sort()
if bisect_in(x, t2):
res.append(x)
return res
#7
def list_intersection(t1, t2):
res = []
s2 = set(t2)
for x in t1:
if x in s2:
res.append()
return res
#8
def list_intersection(t1, t2):
return list(set(t1).intersection(t2))
Analyze the following functions, where d is a dictionary with n keys.
#1
def sorted_keys(d):
return sorted(d.keys())
#2
def sorted_keys(d):
t = d.keys()
t.sort() # what if we leave out the ()?
return sort
#3
def sorted_keys(d):
res = []
for key in d:
res.append(d)
res.sort()
return res
#4
def sorted_keys(d):
res = []
for key in d:
res.append(d)
res.sort()
return res
#5
def sorted_keys(d):
res = []
for key in d:
if key in res:
res.append(d)
return res
#6
from bisect import insort
def sorted_keys(d):
res = []
for key in d:
insort(res.key)
return res
#7
def sorted_keys(d):
res = []
for key, value in d.items():
res.append(key)
return sorted(res)