docstr: Computes test statistic for each stream.
  
  Almost all of the work done here is done in a call to scipy's hypergeom for each window size.
docstr_tok: ["Computes","test","statistic","for","each","stream",".","Almost","all","of","the","work","done","here","is","done","in","a","call","to","scipy","'s","hypergeom","for","each","window","size","."]
code: def _simulate_streams(
      self, x_ref: np.ndarray, pbar: Optional[tqdm]
  ) -> np.ndarray:
      """
      Computes test statistic for each stream.
  
      Almost all of the work done here is done in a call to scipy's hypergeom for each window size.
      """
      n_windows = len(self.window_sizes)
      stats = np.full(
          (self.n_bootstraps, self.t_max, n_windows),
          np.nan,
          dtype=np.float32,
      )
  
      p = np.mean(x_ref)
      sum_ref = np.sum(x_ref)
      x_stream = np.random.choice(
          [False, True], (self.n_bootstraps, self.t_max), p=[1 - p, p]
      )
      cumsums_stream = np.cumsum(x_stream, axis=-1)
      cumsums_stream = np.concatenate(
          [np.zeros_like(cumsums_stream[..., 0:1]), cumsums_stream],
          axis=-1,
      )
      for k in range(n_windows):
          if pbar is not None:
              pbar.update(1)
          ws = self.window_sizes[k]
          cumsums_last_ws = (
              cumsums_stream[:, ws:] - cumsums_stream[:, :-ws]
          )
  
          # Perform FET with hypergeom.cdf (this is vectorised over streams)
          if self.alternative == "greater":
              p_val = hypergeom.cdf(
                  sum_ref,
                  self.n + ws,
                  sum_ref + cumsums_last_ws,
                  self.n,
              )
          else:
              p_val = hypergeom.cdf(
                  cumsums_last_ws,
                  self.n + ws,
                  sum_ref + cumsums_last_ws,
                  ws,
              )
  
          stats[:, (ws - 1) :, k] = self._exp_moving_avg(
              1 - p_val, self.lam
          )
      return stats
  
imports: from tqdm import tqdm
  import numpy
  from typing import Any, Callable, List, Optional, Union
  from alibi_detect.base import DriftConfigMixin
  from alibi_detect.cd.base_online import BaseUniDriftOnline
  from alibi_detect.utils.misc import quantile
  from scipy.stats import hypergeom
  import numba
  import warnings
label_desc: Use image node_id 4 for calling the FETDriftOnline obj's underlying member method code with example usage: obj._simulate_streams(x_ref, pbar) and returns: stats