code: def test_ewma_bootstrap(self):
      t = self.t
      vol = EWMAVariance()
      params = np.array([])
      resids = self.resid
      dist = Normal(seed=self.rng)
      rng = dist.simulate([])
      backcast = vol.backcast(resids)
      var_bounds = vol.variance_bounds(resids)
      with preserved_state(self.rng):
          forecasts = vol.forecast(
              params,
              resids,
              backcast,
              var_bounds,
              horizon=10,
              start=131,
              method="bootstrap",
              rng=rng,
              random_state=self.rng,
          )
  
      sigma2 = np.empty_like(self.resid)
      vol.compute_variance(params, resids, sigma2, backcast, var_bounds)
      std_resids = resids / np.sqrt(sigma2)
  
      one_step = np.empty(t + 1)
      one_step[0] = backcast
      for i in range(1, t + 1):
          one_step[i] = (
              vol.lam * one_step[i - 1]
              + (1 - vol.lam) * resids[i - 1] ** 2
          )
      one_step = one_step[1:]
      paths = np.empty((t, 1000, 10))
      paths.fill(np.nan)
      shocks = np.empty((t, 1000, 10))
      shocks.fill(np.nan)
      for i in range(131, t):
          locs = self.rng.random_sample((1000, 10))
          int_locs = np.floor(locs * (i + 1)).astype(np.int_)
          std_shocks = std_resids[int_locs]
          paths[i, :, 0] = one_step[i]
          shocks[i, :, 0] = np.sqrt(paths[i, :, 0]) * std_shocks[:, 0]
          for j in range(1, 10):
              paths[i, :, j] = (
                  vol.lam * paths[i, :, j - 1]
                  + (1 - vol.lam) * shocks[i, :, j - 1] ** 2
              )
              shocks[i, :, j] = (
                  np.sqrt(paths[i, :, j]) * std_shocks[:, j]
              )
  
      assert_allclose(forecasts.shocks, shocks[131:])
      assert_allclose(forecasts.forecasts, paths[131:].mean(1))
      assert_allclose(forecasts.forecast_paths, paths[131:])
  
      forecasts = vol.forecast(
          params,
          resids,
          backcast,
          var_bounds,
          horizon=10,
          start=252,
          method="simulation",
          rng=rng,
          random_state=self.rng,
      )
      assert forecasts.forecasts.shape == (1000 - 252, 10)
      assert forecasts.forecast_paths.shape == (1000 - 252, 1000, 10)
      assert forecasts.shocks.shape == (1000 - 252, 1000, 10)
      assert np.all(np.isfinite(forecasts.forecasts))
      assert np.all(np.isfinite(forecasts.forecast_paths))
      assert np.all(np.isfinite(forecasts.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 29 for calling the TestVarianceForecasts obj's underlying member method code with example usage: obj.test_ewma_bootstrap() without return types