code: def bootstrap(
      distr, args=(), nobs=200, nrep=100, value=None, batch_size=None
  ):
      """Monte Carlo (or parametric bootstrap) p-values for gof
  
      currently hardcoded for A^2 only
  
      assumes vectorized fit_vec method,
      builds and analyses (nobs, nrep) sample in one step
  
      rename function to less generic
  
      this works also with nrep=1
  
      """
      # signature similar to kstest ?
      # delegate to fn ?
  
      # rvs_kwds = {'size':(nobs, nrep)}
      # rvs_kwds.update(kwds)
  
      # it will be better to build a separate batch function that calls bootstrap
      # keep batch if value is true, but batch iterate from outside if stat is returned
      if batch_size is not None:
          if value is None:
              raise ValueError("using batching requires a value")
          n_batch = int(np.ceil(nrep / float(batch_size)))
          count = 0
          for irep in range(n_batch):
              rvs = distr.rvs(args, **{"size": (batch_size, nobs)})
              params = distr.fit_vec(rvs, axis=1)
              params = lmap(lambda x: np.expand_dims(x, 1), params)
              cdfvals = np.sort(distr.cdf(rvs, params), axis=1)
              stat = asquare(cdfvals, axis=1)
              count += (stat >= value).sum()
          return count / float(n_batch * batch_size)
      else:
          # rvs = distr.rvs(args, **kwds)  #extension to distribution kwds ?
          rvs = distr.rvs(args, **{"size": (nrep, nobs)})
          params = distr.fit_vec(rvs, axis=1)
          params = lmap(lambda x: np.expand_dims(x, 1), params)
          cdfvals = np.sort(distr.cdf(rvs, params), axis=1)
          stat = asquare(cdfvals, axis=1)
          if value is None:  # return all bootstrap results
              stat_sorted = np.sort(stat)
              return stat_sorted
          else:  # calculate and return specific p-value
              return (stat >= value).mean()
  
imports: from statsmodels.compat.python import lmap
  import numpy
  from scipy.stats import distributions
  from statsmodels.tools.decorators import cache_readonly
  from scipy.special import kolmogorov
label_desc: Use image node_id 12 for calling a global function with example usage: bootstrap(distr, args, nobs, nrep, value, batch_size) and returns: unknown, stat_sorted, unknown