I need to create a function that can realize an autoregressive process given three parameters: length(N), standard deviation(sigma), and a vector of coefficients (a).
I know that from the definition of an autoregressive process: x[n]+ ax[n −1]+ ax[n −2]+...+ a[M]x[n − M] = v[n]
Or, in other words: x[n] = -ax[n −1] - ax[n −2] - ... + -a[M]x[n − M] + v[n]
I can use the standard deviation input to create white Gaussian noise with a given variance by multiplying the randn function by it, which will be the v[n] term. However, I'm having trouble figuring out how to create the function since x[n] depends on previous inputs of itself and it can't be an input to the function. As such, I don't know what to do about the x[n-1], x[n-2], etc. terms in the second equation. Does anyone know how to go about doing this? With this issue solved, I can easily figure the rest out on my own. Thanks a lot!