def contrast_allpairs(nm):
 contr = []
 for i in range(nm):
  for j in range((i + 1), nm):
   contr_row = np.zeros(nm)
   contr_row[i] = 1
   contr_row[j] = (-1)
   contr.append(contr_row)
 return np.array(contr)

def contrast_allpairs ( nm ) : contr = [ ] for i in range ( nm ) : for j in range ( ( i + 1 ) , nm ) : contr_row = np . zeros ( nm ) contr_row [ i ] = 1 contr_row [ j ] = ( - 1 ) contr . append ( contr_row ) return np . array ( contr )
contrast or restriction matrix for all pairs of nm variables parameters nm : int returns contr : ndarray .