from __future__ import division
import math
import matplotlib.pyplot as plt
%matplotlib inline
def barplot(vec):
plt.bar(range(len(vec)), vec)
plt.xlim( (-0.2, len(vec)+0.2) )
plt.ylim( (min(0,min(vec)-0.3), max(vec)+0.3) )
plt.axhline(0)
scores = [2.0, -1.0]
barplot(scores)
escores = [math.exp(s) for s in scores]
escores
barplot(escores)
Z = sum(escores)
Z
probs = [escore/Z for escore in escores]
probs
scores = [2, 0.0000001]
escores = [math.exp(s) for s in scores]
probs = [es/sum(escores) for es in escores]
plt.figure(figsize=(20,6))
plt.subplot(131); barplot(scores)
plt.subplot(132); barplot(escores)
plt.subplot(133); barplot(probs)
# IN-CLASS PAIRWISE AGREEMENT RATES
# num_agree: count_of_people_having_that_numagree
counts = {10: 12, 9:13, 8:8, 7:6 }
sum(weight*numright for numright,weight in counts.items()) \
/ sum(counts.values()) / 10.0