code: def test_innovations_algo_filter_kalman_filter(
      ar_params, ma_params, sigma2
  ):
      # Test the innovations algorithm and filter against the Kalman filter
      # for exact likelihood evaluation of an ARMA process
  
      ar = np.r_[1, -ar_params]
      ma = np.r_[1, ma_params]
  
      endog = np.random.normal(size=10)
      nobs = len(endog)
  
      # Innovations algorithm approach
      arma_process_acovf = arma_acovf(ar, ma, nobs=nobs, sigma2=sigma2)
      transformed_acov = _arma_innovations.darma_transformed_acovf_fast(
          ar, ma, arma_process_acovf / sigma2
      )
      acovf, acovf2 = (np.array(mv) for mv in transformed_acov)
      theta, r = _arma_innovations.darma_innovations_algo_fast(
          nobs, ar_params, ma_params, acovf, acovf2
      )
      u = _arma_innovations.darma_innovations_filter(
          endog, ar_params, ma_params, theta
      )
  
      v = np.array(r) * sigma2
      u = np.array(u)
  
      llf_obs = -0.5 * u**2 / v - 0.5 * np.log(2 * np.pi * v)
  
      # Kalman filter apparoach
      mod = SARIMAX(endog, order=(len(ar_params), 0, len(ma_params)))
      res = mod.filter(np.r_[ar_params, ma_params, sigma2])
  
      # Test that the two approaches are identical
      assert_allclose(u, res.forecasts_error[0])
      # assert_allclose(theta[1:, 0], res.filter_results.kalman_gain[0, 0, :-1])
      assert_allclose(llf_obs, res.llf_obs)
  
      # Get llf_obs directly
      llf_obs2 = _arma_innovations.darma_loglikeobs_fast(
          endog, ar_params, ma_params, sigma2
      )
  
      assert_allclose(llf_obs2, res.llf_obs)
  
file_path: statsmodels/statsmodels/tsa/innovations/tests/test_cython_arma_innovations_fast.py
imports: import numpy
  import pytest
  from numpy.testing import assert_equal, assert_allclose
  from statsmodels.tsa.arima_process import arma_acovf
  from statsmodels.tsa.innovations import _arma_innovations, arma_innovations
  from statsmodels.tsa.statespace.sarimax import SARIMAX
label_desc: Use image node_id 3 for calling a global function with example usage: test_innovations_algo_filter_kalman_filter(ar_params, ma_params, sigma2) without return types