comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: pth order auto-regressive process with a specified mean and variance
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: pth order auto-regressive process with a specified mean and variance [message #79210 is a reply to message #79209] Mon, 13 February 2012 07:04 Go to previous messageGo to previous message
Yngvar Larsen is currently offline  Yngvar Larsen
Messages: 134
Registered: January 2010
Senior Member
On Feb 13, 9:19 am, Tom Van Niel <mookiethe...@gmail.com> wrote:
> Hi Guys,
>
> Does anybody have IDL code that simulates a pth order auto-regressive
> process with a specified mean and variance?  If so, please let me
> know.
>

Well. Assuming that the parameters of your AR(p) process is
chosen such that the process is wide-sense stationary, this should be
easy:

xmean = 0.9
xvariance = 1.2
;; This example vector of AR(4) coefficients
;; results in a WSS process.
;; Homework: make sure this is the case yourself.
;; (Hint: Roots of characteristic polynomial
;; within unit circle)
;; My model:
;; X_t = \sum_{i=1}^p a_iX_{t-i} + n_t
;; with n_t iid normal.
;; Array A below contains (after reverse)
;; A = [a_{p-1}, ..., a_2, a_1]
A = reverse([2.7607, -3.8106, 2.6535, -0.9238])
p = n_elements(A)
transient = 1000 ; Transient throwaway points
npoints = 10000 + transient

drive_proc = sqrt(xvariance)*randomn(seed, npoints)
ar_proc = fltarr(npoints)
ar_proc[0] = drive_proc[0]
for ii=1, p-1 do $
ar_proc[ii] = drive_proc[ii] + $
total(A[p-ii:*]*ar_proc[0:ii-1])

for ii=p, npoints-1 do $
ar_proc[ii] = drive_proc[ii] + $
total(A*ar_proc[ii-p:ii-1])

;; Remove transient points, where
;; the process isn't WSS yet.
;; Add mean value.
ar_proc = ar_proc[transient:*] + xmean

--
Yngvar
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: outputting 2D arrays into a txt file
Next Topic: Using both !p.multi and the position keyword (help?)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Dec 03 10:46:42 PST 2025

Total time taken to generate the page: 0.72350 seconds