# Create an ARMA processΒΆ

In this example we are going to build an ARMA process defined by its linear recurrence coefficients.

The creation of an ARMA model requires the data of the AR and MA coefficients which are:

• a list of scalars in the unidmensional case : for the AR-coefficients and for the MA-coefficients

• a list of square matrix for the AR-coefficients and for the MA-coefficients

Il also requires the definition of a white noise that contains the same time grid as the one of the process. The current state of an ARMA model is characterized by its last values and the last values of its white noise. It is possible to get that state thanks to the methods getState. It is possible to create an ARMA with a specific current state. That specific current state is taken into account to generate possible futurs but not to generate realizations (in order to respect the stationarity property of the model). At the creation step, we check whether the process is stationnary. When the process is not stationary, the user is warned by a message.

from __future__ import print_function
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt
import math as m
ot.Log.Show(ot.Log.NONE)


Define the recurrence coefficients AR, MA (4,2)

myARCoef = ot.ARMACoefficients([0.4, 0.3, 0.2, 0.1])
myMACoef = ot.ARMACoefficients([0.4, 0.3])


Define the white noise distribution of the recurrent relation.

myTimeGrid = ot.RegularGrid(0.0, 0.1, 10)
myWhiteNoise = ot.WhiteNoise(ot.Triangular(-1.0, 0.0, 1.0), myTimeGrid)


Create the process:

process = ot.ARMA(myARCoef, myMACoef, myWhiteNoise)
print(process)


Out:

ARMA(X_{0,t} + 0.4 X_{0,t-1} + 0.3 X_{0,t-2} + 0.2 X_{0,t-3} + 0.1 X_{0,t-4} = E_{0,t} + 0.4 E_{0,t-1} + 0.3 E_{0,t-2}, E_t ~ Triangular(a = -1, m = 0, b = 1))


Draw a sample

sample = process.getSample(6)
graph = sample.drawMarginal(0)
view = viewer.View(graph)
plt.show()


Total running time of the script: ( 0 minutes 0.078 seconds)

Gallery generated by Sphinx-Gallery