code: def ewm_bootstrap(
      a, size=None, com=None, span=None, halflife=None, alpha=None
  ):
      
  
      if not any((com, span, halflife, alpha)):
          raise ValueError("Specify one of `com`, `span`, `halflife`, `alpha`.")
      p = ewm_weights(
          i=len(a), com=com, span=span, halflife=halflife, alpha=alpha
      )
      res = np.random.choice(a=a, size=size, p=p)
      return res
docs: Bootstrap a new distribution through exponential weighting.
  
      Parameters
      ----------
      a : 1-D array-like
          Array from which to generate random sample of elements
      size : int or tuple of ints, default None
          Output shape.  If None, a single value is returned
      com : float, default None
          Center of mass; alpha = 1 / (1 + com), for com ≥ 0
      span : float, default None
          Span parameter; a = 2 / (span + 1), for span ≥ 1
      halflife : float, default None
          Halflife parameter; alpha = 1 − exp(log(0.5) / halflife),
          for halflife > 0
      alpha : float, default None
          Smoothing factor
  
      Example
      -------
      >>> import pandas as pd
      >>> np.random.seed(123)
  
      # Our bootstrapped histogram should approximate these freqs
      >>> ewm_weights(10, alpha=.10)
      [ 0.05948221  0.06609135  0.07343483  0.08159426  0.09066029  0.10073365
        0.11192628  0.12436253  0.13818059  0.15353399]
  
      >>> res = ewm_bootstrap(np.arange(10), size=int(1e6), alpha=.10)
      >>> res = pd.Series(res).value_counts()
      >>> (res / res.sum()).head()
      9    0.15323
      8    0.13834
      7    0.12424
      6    0.11189
      5    0.10113
      dtype: float64