def guess_lag(x, y):
 if (len(x) != len(y)):
  return 0
 diffs = []
 indexes = range(len(x))
 for i in indexes:
  if ((i + 1) not in indexes):
   continue
  diffs.append((y[(i + 1)] - y[i]))
 diffs = np.array(diffs)
 flex = x[(-1)]
 for i in indexes:
  if ((i + 1) not in indexes):
   continue
  if ((y[(i + 1)] - y[i]) > (diffs.mean() + diffs.std())):
   flex = x[i]
   break
 return flex

def guess_lag ( x , y ) : if ( len ( x ) != len ( y ) ) : return 0 diffs = [ ] indexes = range ( len ( x ) ) for i in indexes : if ( ( i + 1 ) not in indexes ) : continue diffs . append ( ( y [ ( i + 1 ) ] - y [ i ] ) ) diffs = np . array ( diffs ) flex = x [ ( - 1 ) ] for i in indexes : if ( ( i + 1 ) not in indexes ) : continue if ( ( y [ ( i + 1 ) ] - y [ i ] ) > ( diffs . mean ( ) + diffs . std ( ) ) ) : flex = x [ i ] break return flex
given two axes returns a guess of the lag point .