Reader small image

You're reading from  Learning NumPy Array

Product typeBook
Published inJun 2014
Reading LevelIntermediate
Publisher
ISBN-139781783983902
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Ivan Idris
Ivan Idris
author image
Ivan Idris

Ivan Idris has an MSc in experimental physics. His graduation thesis had a strong emphasis on applied computer science. After graduating, he worked for several companies as a Java developer, data warehouse developer, and QA analyst. His main professional interests are business intelligence, big data, and cloud computing. Ivan Idris enjoys writing clean, testable code and interesting technical articles. Ivan Idris is the author of NumPy 1.5. Beginner's Guide and NumPy Cookbook by Packt Publishing.
Read more about Ivan Idris

Right arrow

The Autoregressive Moving Average temperature model


The Autoregressive Moving Average (ARMA) model mixes the Autoregressive (AR) and Moving Average (MA) models. We have already discussed both models. Informally, we can say that we have the autoregressive component with white noise around it. Part of this white noise can be modeled as a linear combination of lag components plus some constant as follows:

  1. Define an autoregressive model with lag 2 using linear coefficients we obtained with a previous script:

    def ar(a):
       ar_p = [1.06517683, -0.08293789]
     
       return ar_p[0] * a[1:-1] + ar_p[1] * a[:-2]
  2. Define the moving average model with lag 1:

    def model(p, ma1):
       c0, c1 = p
     
       return c0 + c1 * ma1
  3. Subtract the autoregressive model values from the data, giving us the error terms (white noise):

    err_terms = temp[cutoff+1:] - ar(temp[cutoff-1:])

    Most of the code for this model should appear familiar to you as shown in the following code:

    import sys
    import numpy as np
    import matplotlib.pyplot as plt...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning NumPy Array
Published in: Jun 2014Publisher: ISBN-13: 9781783983902

Author (1)

author image
Ivan Idris

Ivan Idris has an MSc in experimental physics. His graduation thesis had a strong emphasis on applied computer science. After graduating, he worked for several companies as a Java developer, data warehouse developer, and QA analyst. His main professional interests are business intelligence, big data, and cloud computing. Ivan Idris enjoys writing clean, testable code and interesting technical articles. Ivan Idris is the author of NumPy 1.5. Beginner's Guide and NumPy Cookbook by Packt Publishing.
Read more about Ivan Idris