def mixing_dict(xy, normalized=False):
 d = {}
 psum = 0.0
 for (x, y) in xy:
  if (x not in d):
   d[x] = {}
  if (y not in d):
   d[y] = {}
  v = d[x].get(y, 0)
  d[x][y] = (v + 1)
  psum += 1
 if normalized:
  for (k, jdict) in d.items():
   for j in jdict:
    jdict[j] /= psum
 return d

def mixing_dict ( xy , normalized = False ) : d = { } psum = 0.0 for ( x , y ) in xy : if ( x not in d ) : d [ x ] = { } if ( y not in d ) : d [ y ] = { } v = d [ x ] . get ( y , 0 ) d [ x ] [ y ] = ( v + 1 ) psum += 1 if normalized : for ( k , jdict ) in d . items ( ) : for j in jdict : jdict [ j ] /= psum return d
return a dictionary representation of mixing matrix .