def sorensen_coefficient(X, Y):
 if (X is Y):
  X = Y = np.asanyarray(X)
 else:
  X = np.asanyarray(X)
  Y = np.asanyarray(Y)
 XY = []
 i = 0
 for arrayX in X:
  XY.append([])
  for arrayY in Y:
   XY[i].append(((2 * np.intersect1d(arrayX, arrayY).size) / float((len(arrayX) + len(arrayY)))))
  XY[i] = np.array(XY[i])
  i += 1
 XY = np.array(XY)
 return XY

def sorensen_coefficient ( X , Y ) : if ( X is Y ) : X = Y = np . asanyarray ( X ) else : X = np . asanyarray ( X ) Y = np . asanyarray ( Y ) XY = [ ] i = 0 for arrayX in X : XY . append ( [ ] ) for arrayY in Y : XY [ i ] . append ( ( ( 2 * np . intersect1d ( arrayX , arrayY ) . size ) / float ( ( len ( arrayX ) + len ( arrayY ) ) ) ) ) XY [ i ] = np . array ( XY [ i ] ) i += 1 XY = np . array ( XY ) return XY
considering the rows of x as vectors .