def arma_periodogram(ar, ma, worN=None, whole=0):
 (w, h) = signal.freqd(ma, ar, worN=worN, whole=whole)
 sd = ((np.abs(h) ** 2) / np.sqrt((2 * np.pi)))
 if (np.sum(np.isnan(h)) > 0):
  print('Warning: nan in frequency response h, maybe a unit root')
 return (w, sd)

def arma_periodogram ( ar , ma , worN = None , whole = 0 ) : ( w , h ) = signal . freqd ( ma , ar , worN = worN , whole = whole ) sd = ( ( np . abs ( h ) ** 2 ) / np . sqrt ( ( 2 * np . pi ) ) ) if ( np . sum ( np . isnan ( h ) ) > 0 ) : print ( 'Warning: nan in frequency response h, maybe a unit root' ) return ( w , sd )
periodogram for arma process given by lag-polynomials ar and ma parameters ar : array_like autoregressive lag-polynomial with leading 1 and lhs sign ma : array_like moving average lag-polynomial with leading 1 worn : {none .