code: def test_figarch_recursion(self):
      nobs, resids = self.nobs, self.resids
      sigma2, backcast = self.sigma2, self.backcast
      parameters = np.array([1.0, 0.2, 0.4, 0.3])
      fresids = resids**2
      p = q = 1
      trunc_lag = 1000
      rec.figarch_recursion(
          parameters,
          fresids,
          sigma2,
          p,
          q,
          nobs,
          trunc_lag,
          backcast,
          self.var_bounds,
      )
      lam = rec.figarch_weights(
          parameters[1:], p, q, trunc_lag=trunc_lag
      )
      lam_rev = lam[::-1]
      omega_tilde = parameters[0] / (1 - parameters[-1])
      sigma2_direct = np.empty_like(sigma2)
      for t in range(nobs):
          backcasts = trunc_lag - t
          sigma2_direct[t] = omega_tilde
          if backcasts:
              sigma2_direct[t] += backcast * lam_rev[:backcasts].sum()
          if t:
              sigma2_direct[t] += np.sum(
                  lam_rev[-t:] * fresids[max(0, t - 1000) : t]
              )
      assert_almost_equal(sigma2_direct, sigma2)
  
      recpy.figarch_recursion(
          parameters,
          fresids,
          sigma2,
          p,
          q,
          nobs,
          trunc_lag,
          backcast,
          self.var_bounds,
      )
      sigma2_numba = sigma2.copy()
      recpy.figarch_recursion_python(
          parameters,
          fresids,
          sigma2,
          p,
          q,
          nobs,
          trunc_lag,
          backcast,
          self.var_bounds,
      )
      sigma2_python = sigma2.copy()
      rec.figarch_recursion(
          parameters,
          fresids,
          sigma2,
          p,
          q,
          nobs,
          trunc_lag,
          backcast,
          self.var_bounds,
      )
      assert_almost_equal(sigma2_numba, sigma2)
      assert_almost_equal(sigma2_python, sigma2)
  
imports: import os
  import pickle
  import timeit
  import types
  import numpy
  from numpy.random import RandomState
  from numpy.testing import assert_allclose, assert_almost_equal
  import pytest
  from scipy.special import gamma
  import arch.univariate.recursions_python
  from arch.univariate.volatility import RiskMetrics2006
label_desc: Use image node_id 17 for calling the TestRecursions obj's underlying member method code with example usage: obj.test_figarch_recursion() without return types