code: def test_harch_forecast_simulation(self):
      t = self.t
      vol = HARCH(lags=[1, 5, 22])
      dist = Normal(seed=self.rng)
      rng = dist.simulate([])
      params = np.array([3.0, 0.4, 0.3, 0.2])
      resids = self.resid
      backcast = vol.backcast(resids)
      var_bounds = vol.variance_bounds(resids)
      with preserved_state(self.rng):
          forecast = vol.forecast(
              params,
              resids,
              backcast,
              var_bounds,
              horizon=10,
              start=0,
              rng=rng,
              method="simulation",
          )
  
      resids2 = np.zeros((t, 22 + 10))
      resids2.fill(backcast)
      for i in range(22):
          resids2[21 - i :, i] = resids[: (t - 21 + i)] ** 2.0
      paths = np.zeros((t, 1000, 10))
      shocks = np.zeros((t, 1000, 10))
      const = 3.0
      arch = np.zeros(22)
      arch[0] = 0.4
      arch[:5] += 0.3 / 5
      arch[:22] += 0.2 / 22
      for i in range(t):
          std_shocks = rng((1000, 10))
          temp = np.empty((1000, 32))
          temp[:, :22] = resids2[i : i + 1, :22]
          for j in range(10):
              paths[i, :, j] = const + temp[:, j : 22 + j].dot(
                  arch[::-1]
              )
              shocks[i, :, j] = std_shocks[:, j] * np.sqrt(
                  paths[i, :, j]
              )
              temp[:, 22 + j] = shocks[i, :, j] ** 2.0
  
      forecasts = paths.mean(1)
  
      assert_allclose(forecast.forecasts, forecasts)
      assert_allclose(forecast.forecast_paths, paths)
      assert_allclose(forecast.shocks, shocks)
  
imports: import numpy
  from numpy.random import RandomState
  from numpy.testing import assert_allclose
  import pandas
  import pytest
  from arch.univariate import arch_model
  from arch.univariate.distribution import Normal, StudentsT
  from arch.univariate.mean import ConstantMean
  from arch.univariate.volatility import APARCH, EGARCH, FIGARCH, GARCH, HARCH, BootstrapRng, ConstantVariance, EWMAVariance, FixedVariance, MIDASHyperbolic, RiskMetrics2006
label_desc: Use image node_id 16 for calling the TestVarianceForecasts obj's underlying member method code with example usage: obj.test_harch_forecast_simulation() without return types