# autoregressive moving average code implementation

I am new to DSP and i am trying to take a wav (human speech) file and apply ARMA filter and plot its PSD graph in python.

I see that there are a lot of AR implementations but almost none ARMA. I found only statsmodel that implemented ARMA but it requires the data to be stationary (but sound with lags of 30 is almost stationary)

Does anyone have a working piece of code that i can use to plot? If not, i will be happy to get some reference on how to implement it.

• Awesome. Just the other day I noticed that people were using ARMA for speech. I am guessing that when LPC was developed for speech, more than 40 years ago, it would been expensive to do the calculations which could explain why they chose a model that is simpler than ARMA. – richard mullins Aug 25 '17 at 11:47
• are you looking to estimate the ARMA parameters? – Stanley Pawlukiewicz Oct 24 '17 at 16:41

I dont know in Python, but this simple matlab/octave loop code:

function y=arma(x,A,B)
na=length(A);
n=length(x);
y(1:na,1)=zeros(na,1);
for i=na:n
y(i,1)=1/A(1)*A(2:na)*y(i-1:-1:i-na+1)+1/A(1)*B*x(i:-1:i-na+1);
end


Implements a ARMA filter, with polynomials $A$, $B$, such as per this 5th order filter:

A=[1 0 0 0 0 0];
B=[0 0.2 0.2 0.2 0.2 0.2];
n=1000; dt=0.001;
t=dt*(0:n-1)';
x=randn(n,1);
y=arma(x,A,B);
plot(t,[x y]);