<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> from matplotlib import pyplot as plt <EOL> from nitime import utils <EOL> from nitime import algorithms as alg <EOL> from nitime . timeseries import TimeSeries <EOL> from nitime . viz import plot_tseries <EOL> """<STR_LIT>""" <EOL> npts = <NUM_LIT> <EOL> sigma = <NUM_LIT:0.1> <EOL> drop_transients = <NUM_LIT> <EOL> Fs = <NUM_LIT:1000> <EOL> """<STR_LIT>""" <EOL> coefs = np . array ( [ <NUM_LIT> , - <NUM_LIT:0.5> ] ) <EOL> """<STR_LIT>""" <EOL> X , noise , _ = utils . ar_generator ( npts , sigma , coefs , drop_transients ) <EOL> ts_x = TimeSeries ( X , sampling_rate = Fs , time_unit = '<STR_LIT:s>' ) <EOL> ts_noise = TimeSeries ( noise , sampling_rate = <NUM_LIT:1000> , time_unit = '<STR_LIT:s>' ) <EOL> """<STR_LIT>""" <EOL> fig01 = plot_tseries ( ts_x , label = '<STR_LIT>' ) <EOL> fig01 = plot_tseries ( ts_noise , fig = fig01 , label = '<STR_LIT>' ) <EOL> fig01 . axes [ <NUM_LIT:0> ] . legend ( ) <EOL> """<STR_LIT>""" <EOL> coefs_est , sigma_est = alg . AR_est_YW ( X , <NUM_LIT:2> ) <EOL> X_hat , _ , _ = utils . ar_generator ( <EOL> N = npts , sigma = sigma_est , coefs = coefs_est , drop_transients = <NUM_LIT:100> , v = noise <EOL> ) <EOL> fig02 = plt . figure ( ) <EOL> ax = fig02 . add_subplot ( <NUM_LIT> ) <EOL> ax . plot ( np . arange ( <NUM_LIT:100> , len ( X_hat ) + <NUM_LIT:100> ) , X_hat , label = '<STR_LIT>' ) <EOL> ax . plot ( X , '<STR_LIT>' , label = '<STR_LIT>' ) <EOL> ax . legend ( ) <EOL> err = X_hat - X [ <NUM_LIT:100> : ] <EOL> mse = np . dot ( err , err ) / len ( X_hat ) <EOL> ax . set_title ( '<STR_LIT>' % mse ) <EOL> plt . show ( ) </s>
