def get_avg_dists(state1_samids, state2_samids, distdict):
 state1_avg_dists = []
 for sam1 in state1_samids:
  dists = []
  for sam2 in state2_samids:
   if (sam1 == sam2):
    continue
   dists.append(distdict[sam1][sam2])
  state1_avg_dists.append(numpy.mean(dists))
 return state1_avg_dists

def get_avg_dists ( state1_samids , state2_samids , distdict ) : state1_avg_dists = [ ] for sam1 in state1_samids : dists = [ ] for sam2 in state2_samids : if ( sam1 == sam2 ) : continue dists . append ( distdict [ sam1 ] [ sam2 ] ) state1_avg_dists . append ( numpy . mean ( dists ) ) return state1_avg_dists
foreach sample in stat1_sams .