original_docstring: 
      Generates surrogate map of `y`, retaining characteristic spatial features
  
      Parameters
      ----------
      x : array_like
          Distance matrix
      y : array_like
          Dependent brain-imaging variable; all values must be positive
      rho : float, optional
          Estimate for rho parameter. If not provided will be estimated from
          input data. Default: None
      d0 : float, optional
          Estimate for d0 parameter. If not provided will be estimated from input
          data. Default: None
      return_order : bool, optional
          Whether to return rank order of generated `surrogate` before values
          were replaced with `y`
  
      Returns
      -------
      surrogate : array_like
          Input `y` matrix, permuted according to surrogate map with similar
          spatial autocorrelation factor
      order : array_like
          Rank-order of `surrogate` before values were replaced with `y`
      
docstring: Generates surrogate map of `y`, retaining characteristic spatial features
  Parameters
  
  x : array_like
  Distance matrix
  y : array_like
  Dependent brain-imaging variable; all values must be positive
  rho : float, optional
  Estimate for rho parameter. If not provided will be estimated from
  input data. Default: None
  d0 : float, optional
  Estimate for d0 parameter. If not provided will be estimated from input
  data. Default: None
  return_order : bool, optional
  Whether to return rank order of generated `surrogate` before values
  were replaced with `y`
  
  Returns
  
  
docstring_tokens: Generates surrogate map of ` y ` retaining characteristic spatial features Parameters x : array_like Distance matrix y : array_like Dependent brain - imaging variable ; all values must be positive rho : float optional Estimate for rho parameter . If not provided will be estimated from input data . Default : None d0 : float optional Estimate for d0 parameter . If not provided will be estimated from input data . Default : None return_order : bool optional Whether to return rank order of generated ` surrogate ` before values were replaced with ` y ` Returns
code: def make_surrogate(x, y, rho=None, d0=None, seed=None, return_order=False,
                     return_params=False):
      """
      Generates surrogate map of `y`, retaining characteristic spatial features
  
      Parameters
      ----------
      x : array_like
          Distance matrix
      y : array_like
          Dependent brain-imaging variable; all values must be positive
      rho : float, optional
          Estimate for rho parameter. If not provided will be estimated from
          input data. Default: None
      d0 : float, optional
          Estimate for d0 parameter. If not provided will be estimated from input
          data. Default: None
      return_order : bool, optional
          Whether to return rank order of generated `surrogate` before values
          were replaced with `y`
  
      Returns
      -------
      surrogate : array_like
          Input `y` matrix, permuted according to surrogate map with similar
          spatial autocorrelation factor
      order : array_like
          Rank-order of `surrogate` before values were replaced with `y`
      """
  
      # new random seed
      rs = np.random.default_rng(seed)
  
      if rho is None or d0 is None:
          rho, d0 = estimate_rho_d0(x, y, rho=rho, d0=d0)
  
      # "using best-fit parameters rho_hat and d0_hat, surrogate maps y_surr"
      # "are generated according to y_surr = (I - rho_hat * W[d0_hat])^-1 * u"
      # "where u ~ normal(0, 1)"
      w = _make_weight_matrix(x, d0)
      u = rs.standard_normal(len(x))
      i = np.identity(len(x))
      surr = np.linalg.solve(i - rho * w, u)
  
      # "to match surrogate map value distributions to the distributon of values"
      # "in the corresponding empirical map, rank-ordered surrogate map values"
      # "were re-assigned the corresponding rank-ordered values in the empirical"
      # "data"
      order = surr.argsort()
      surr[order] = np.sort(y)
  
      out = (surr,)
  
      if return_order:
          out += (order,)
      if return_params:
          out += ((rho, d0),)
  
      return out[0] if len(out) == 1 else out
code_tokens: def make_surrogate ( x , y , rho = None , d0 = None , seed = None , return_order = False , return_params = False ) : rs = np . random . default_rng ( seed ) if rho is None or d0 is None : rho , d0 = estimate_rho_d0 ( x , y , rho = rho , d0 = d0 ) w = _make_weight_matrix ( x , d0 ) u = rs . standard_normal ( len ( x ) ) i = np . identity ( len ( x ) ) surr = np . linalg . solve ( i - rho * w , u ) order = surr . argsort ( ) surr [ order ] = np . sort ( y ) out = ( surr , ) if return_order : out += ( order , ) if return_params : out += ( ( rho , d0 ) , ) return out [ 0 ] if len ( out ) == 1 else out
short_docstring: Generates surrogate map of `y`, retaining characteristic spatial features
  Parameters
short_docstring_tokens: Generates surrogate map of ` y ` retaining characteristic spatial features Parameters
comment: """
      Generates surrogate map of `y`, retaining characteristic spatial features
  
      Parameters
      ----------
      x : array_like
          Distance matrix
      y : array_like
          Dependent brain-imaging variable; all values must be positive
      rho : float, optional
          Estimate for rho parameter. If not provided will be estimated from
          input data. Default: None
      d0 : float, optional
          Estimate for d0 parameter. If not provided will be estimated from input
          data. Default: None
      return_order : bool, optional
          Whether to return rank order of generated `surrogate` before values
          were replaced with `y`
  
      Returns
      -------
      surrogate : array_like
          Input `y` matrix, permuted according to surrogate map with similar
          spatial autocorrelation factor
      order : array_like
          Rank-order of `surrogate` before values were replaced with `y`
      """$SEP$# new random seed$SEP$# "using best-fit parameters rho_hat and d0_hat, surrogate maps y_surr"$SEP$# "are generated according to y_surr = (I - rho_hat * W[d0_hat])^-1 * u"$SEP$# "where u ~ normal(0, 1)"$SEP$# "to match surrogate map value distributions to the distributon of values"$SEP$# "in the corresponding empirical map, rank-ordered surrogate map values"$SEP$# "were re-assigned the corresponding rank-ordered values in the empirical"$SEP$# "data"