def get_avg_edit_dist(seqs): n = len(seqs) avg = 0 dists = np.zeros((n, n)) for i in range(n): for j in range(i,n): dists[i][j] = edit_dist(seqs[i], seqs[j]) avg += dists[i][j] avg /= float(n*(n-1)/2) return avg
def get_weekday_sum_avg_edit_dist(weekday_seqs): #fp = r"C:\Users\Sophie\Smart Phone Project Local\by subjects\wifigps_subject04.csv" sum = 0 for pair in weekday_seqs: seqs = pair[1] n = len(seqs) avg = 0 dists = np.zeros((n, n)) for i in range(n): for j in range(i,n): dists[i][j] = edit_dist(seqs[i], seqs[j]) avg += dists[i][j] avg /= float(n*(n-1)/2) sum += avg print sum return sum