[Numpy-discussion] simulate AR

josef.pktd@gmai... josef.pktd@gmai...
Fri Oct 14 11:21:43 CDT 2011


On Fri, Oct 14, 2011 at 11:56 AM, Fabrice Silva <silva@lma.cnrs-mrs.fr> wrote:
> Le vendredi 14 octobre 2011 à 10:49 -0400, josef.pktd@gmail.com a
> écrit :
>> On Fri, Oct 14, 2011 at 10:24 AM, Alan G Isaac <alan.isaac@gmail.com> wrote:
>> > As a simple example, if I have y0 and a white noise series e,
>> > what is the best way to produces a series y such that y[t] = 0.9*y[t-1] + e[t]
>> > for t=1,2,...?
>> >
>> > 1. How can I best simulate an autoregressive process using NumPy?
>> >
>> > 2. With SciPy, it looks like I could do this as
>> > e[0] = y0
>> > signal.lfilter((1,),(1,-0.9),e)
>> > Am I overlooking similar (or substitute) functionality in NumPy?
>>
>> I don't think so. At least I didn't find anything in numpy for this.
>> An MA process would be a convolution, but for simulating AR I only
>> found signal.lfilter. (unless numpy has gained extra features that I
>> don't have in 1.5)
>>
>> Except, I think it's possible to do it with fft, if you want to
>> fft-inverse-convolve (?)
>> But simulating an ARMA with fft was much slower than lfilter in my
>> short experimentation with it.
>
> About speed comparison between lfilter, convolve, etc...
> http://www.scipy.org/Cookbook/ApplyFIRFilter

One other way to simulate the AR is to get the (truncated)
MA-representation, and then convolve can be used, as in
AppluFIRFilter.

numpy polynomials can be used it invert the AR-polynomial (with a bit
of juggling.)

Josef

>
> --
> Fabrice Silva
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list