In [2]:
from __future__ import division
import math
import matplotlib.pyplot as plt
%matplotlib inline
In [3]:
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)
In [4]:
scores = [2.0, -1.0]
barplot(scores)
In [5]:
escores = [math.exp(s) for s in scores]
escores
Out[5]:
[7.38905609893065, 0.36787944117144233]
In [6]:
barplot(escores)
In [7]:
Z = sum(escores)
Z
Out[7]:
7.756935540102093
In [8]:
probs = [escore/Z for escore in escores]
probs
Out[8]:
[0.9525741268224331, 0.04742587317756678]
In [12]:
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 []:
 
In [1]:
# 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
Out[1]:
0.8
In [19]:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []:
 
In []: