def _yule_walker(X, order=1):
 assert (X.ndim == 2)
 denom = (X.shape[(-1)] - np.arange((order + 1)))
 r = np.zeros((order + 1), np.float64)
 for (di, d) in enumerate(X):
  d -= d.mean()
  r[0] += np.dot(d, d)
  for k in range(1, (order + 1)):
   r[k] += np.dot(d[0:(- k)], d[k:])
 r /= (denom * len(X))
 rho = linalg.solve(linalg.toeplitz(r[:(-1)]), r[1:])
 sigmasq = (r[0] - (r[1:] * rho).sum())
 return (rho, np.sqrt(sigmasq))

def _yule_walker ( X , order = 1 ) : assert ( X . ndim == 2 ) denom = ( X . shape [ ( - 1 ) ] - np . arange ( ( order + 1 ) ) ) r = np . zeros ( ( order + 1 ) , np . float64 ) for ( di , d ) in enumerate ( X ) : d -= d . mean ( ) r [ 0 ] += np . dot ( d , d ) for k in range ( 1 , ( order + 1 ) ) : r [ k ] += np . dot ( d [ 0 : ( - k ) ] , d [ k : ] ) r /= ( denom * len ( X ) ) rho = linalg . solve ( linalg . toeplitz ( r [ : ( - 1 ) ] ) , r [ 1 : ] ) sigmasq = ( r [ 0 ] - ( r [ 1 : ] * rho ) . sum ( ) ) return ( rho , np . sqrt ( sigmasq ) )
compute yule-walker .