class_docstr: State space model for an autoregressive moving average process.
  
  A state space model (SSM) posits a set of latent (unobserved) variables that
  evolve over time with dynamics specified by a probabilistic transition model
  `p(z[t+1] | z[t])`. At each timestep, we observe a value sampled from an
  observation model conditioned on the current state, `p(x[t] | z[t])`. The
  special case where both the transition and observation models are Gaussians
  with mean specified as a linear function of the inputs, is known as a linear
  Gaussian state space model and supports tractable exact probabilistic
  calculations; see `tfp.distributions.LinearGaussianStateSpaceModel` for
  details.
  
  In an autoregressive moving average (ARMA) process, the expected level at
  each timestep is a linear function of previous levels, with added Gaussian
  noise, and a linear function of previous Gaussian noise:
  
  ```python
  level[t + 1] = (
    level_drift
    + noise[t + 1]
    + sum(ar_coefficients * levels[t:t-order:-1])
    + sum(ma_coefficients * noise[t:t-order:-1]))
  noise[t + 1] ~ Normal(0., scale=level_scale)
  ```
  
  The process is characterized by a vector `coefficients` whose size
  determines the order of the process (how many previous values it looks at),
  and by `level_scale`, the standard deviation of the noise added at each
  step.
  
  This is formulated as a state space model by letting the latent state encode
  the most recent values; see 'Mathematical Details' below.
  
  The parameters `level_scale` and `observation_noise_scale` are each (a batch
  of) scalars, and `coefficients` is a (batch) vector of size `[order]`. The
  batch shape of this `Distribution` is the broadcast batch
  shape of these parameters and of the `initial_state_prior`.
  
  #### Mathematical Details
  
  The Hamilton autoregressive moving average model implements a
  `tfp.distributions.LinearGaussianStateSpaceModel` with `latent_size = order`
  and `observation_size = 1`. The latent state vector encodes the recent
  history of the process, with the current value in the topmost dimension. At
  each timestep, the transition sums the previous values to produce the new
  expected value, shifts all other values down by a dimension, and adds noise
  to the current value. This is formally encoded by the transition model:
  
  ```
  transition_matrix = [ ar_coefs[0],  ar_coefs[1],    ..., ar_coefs[p]
                        1.,           0,              ..., 0.
                        0.,           1,              ..., 0.
                        ...
                        0.,           0.,  ...,       1.,  0.   ]
  
  transition_noise ~ N(loc=level_drift / (1. + sum(ma_coefficients)),
                       scale=diag([level_scale, 0., 0., ..., 0.]))
  ```
  
  The observation model simply extracts the current (topmost) value,
  sums the previous noise and optionally adds independent noise at each step:
  
  ```
  observation_matrix = [1, ma_coefs[0], ma_coefs[1], ..., ma_coefs[p-1]]
  observation_noise ~ N(loc=0, scale=observation_noise_scale)
  ```
  
  Models with `observation_noise_scale = 0.` are ARMA(p, p-1) processes
  in the formal sense. Setting `observation_noise_scale` to a nonzero value
  corresponds to a latent ARMA(p, p-1) process observed under an iid noise
  model.
  
  #### References
  
  [1] James D. Hamilton. State-space models. __Handbook of Econometrics,
      Volume IV__ (1994): 3039-3080.
      http://web.pdx.edu/~crkl/readings/Hamilton94.pdf
code: def order(self):
      return self._order
  
file_path: probability/tensorflow_probability/python/sts/components/autoregressive_moving_average.py
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import linear_gaussian_ssm
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.sts.components.autoregressive import make_ar_transition_matrix
  from tensorflow_probability.python.sts.internal import util
label_desc: Use image node_id 2 for calling the AutoregressiveMovingAverageStateSpaceModel obj's underlying member method code with example usage: obj.order() and returns: self