original_docstring: Compute the level number variance of the current unfolded eigenvalues.
  
      Parameters
      ----------
      L: float
          The current L value to use for computation.
  
      tol: float
          Stop iterating when the last `min_iters` computed values of the
          level variance have a range (i.e. max - min) < tol
  
      max_iters: int
          Stop computing values for the level variance once max_iters values
          have been computed
  
      min_iters: int
          Minimum number of iterations
  
  
      Returns
      -------
      sigma: float
          The computed level variance for L.
  
      Notes
      -----
      Computes the level number variance by randomly selecting a point c in
      the interval [unfolded.min(), unfolded.max()], and counts the number
      of unfolded eigenvalues in (c - L/2, c + L/2) to determine a value for
      the level number variance, sigma(L). The process is repeated until the
      running averages stabilize, and the final running average is returned.
      
docstring: Compute the level number variance of the current unfolded eigenvalues.
  Parameters
  
  float
  The current L value to use for computation.
  
  float
  Stop iterating when the last `min_iters` computed values of the
  level variance have a range  < tol
  
  int
  Stop computing values for the level variance once max_iters values
  have been computed
  
  int
  Minimum number of iterations
  
  Returns
  
  float
  The computed level variance for L.
  
  Notes
  
  Computes the level number variance by randomly selecting a point c in
  the interval [unfolded.min(), unfolded.max()], and counts the number
  of unfolded eigenvalues in (c - L/2, c + L/2) to determine a value for
  the level number variance, sigma(L). The process is repeated until the
  running averages stabilize, and the final running average is returned.
docstring_tokens: Compute the level number variance of the current unfolded eigenvalues . Parameters float The current L value to use for computation . float Stop iterating when the last ` min_iters ` computed values of the level variance have a range < tol int Stop computing values for the level variance once max_iters values have been computed int Minimum number of iterations Returns float The computed level variance for L . Notes Computes the level number variance by randomly selecting a point c in the interval [ unfolded . min () unfolded . max () ] and counts the number of unfolded eigenvalues in ( c - L / 2 c + L / 2 ) to determine a value for the level number variance sigma ( L ) . The process is repeated until the running averages stabilize and the final running average is returned .
code: def _sigma_iter_converge_L(
      unfolded: ndarray, L: float, tol: float, max_iters: int, min_iters: int
  ) -> Any:
      """Compute the level number variance of the current unfolded eigenvalues.
  
      Parameters
      ----------
      L: float
          The current L value to use for computation.
  
      tol: float
          Stop iterating when the last `min_iters` computed values of the
          level variance have a range (i.e. max - min) < tol
  
      max_iters: int
          Stop computing values for the level variance once max_iters values
          have been computed
  
      min_iters: int
          Minimum number of iterations
  
  
      Returns
      -------
      sigma: float
          The computed level variance for L.
  
      Notes
      -----
      Computes the level number variance by randomly selecting a point c in
      the interval [unfolded.min(), unfolded.max()], and counts the number
      of unfolded eigenvalues in (c - L/2, c + L/2) to determine a value for
      the level number variance, sigma(L). The process is repeated until the
      running averages stabilize, and the final running average is returned.
      """
      level_mean = 0.0
      level_sq_mean = 0.0
      sigma = 0.0
      size = min_iters
      sigmas = np.zeros((size), dtype=np.float64)  # hold the last `size` running averages
  
      c = np.random.uniform(np.min(unfolded), np.max(unfolded))
      start, end = c - L / 2, c + L / 2
      n_within = len(unfolded[(unfolded >= start) & (unfolded <= end)])
      n_within_sq = n_within * n_within
      level_mean, level_sq_mean = n_within, n_within_sq
      sigma = level_sq_mean - level_mean * level_mean
      sigmas[0] = sigma
  
      # we'll use the fact that for x = [x_0, x_1, ... x_n-1], the
      # average a_k == (k*a_(k-1) + x_k) / (k+1) for k = 0, ..., n-1
      k = 0
      while True:
          k += 1
          c = np.random.uniform(np.min(unfolded), np.max(unfolded))
          start, end = c - L / 2, c + L / 2
          n_within = len(unfolded[(unfolded >= start) & (unfolded <= end)])
          n_within_sq = n_within * n_within
          level_mean = (k * level_mean + n_within) / (k + 1)
          level_sq_mean = (k * level_sq_mean + n_within_sq) / (k + 1)
          sigma = level_sq_mean - level_mean * level_mean
          sigmas[k % size] = sigma
          if np.abs(np.max(sigmas) - np.min(sigmas)) < tol and k > min_iters:
              break
          if k > max_iters:
              break
  
      return sigma
code_tokens: def _sigma_iter_converge_L ( unfolded : ndarray , L : float , tol : float , max_iters : int , min_iters : int ) -> Any : level_mean = 0.0 level_sq_mean = 0.0 sigma = 0.0 size = min_iters sigmas = np . zeros ( ( size ) , dtype = np . float64 ) c = np . random . uniform ( np . min ( unfolded ) , np . max ( unfolded ) ) start , end = c - L / 2 , c + L / 2 n_within = len ( unfolded [ ( unfolded >= start ) & ( unfolded <= end ) ] ) n_within_sq = n_within * n_within level_mean , level_sq_mean = n_within , n_within_sq sigma = level_sq_mean - level_mean * level_mean sigmas [ 0 ] = sigma k = 0 while True : k += 1 c = np . random . uniform ( np . min ( unfolded ) , np . max ( unfolded ) ) start , end = c - L / 2 , c + L / 2 n_within = len ( unfolded [ ( unfolded >= start ) & ( unfolded <= end ) ] ) n_within_sq = n_within * n_within level_mean = ( k * level_mean + n_within ) / ( k + 1 ) level_sq_mean = ( k * level_sq_mean + n_within_sq ) / ( k + 1 ) sigma = level_sq_mean - level_mean * level_mean sigmas [ k % size ] = sigma if np . abs ( np . max ( sigmas ) - np . min ( sigmas ) ) < tol and k > min_iters : break if k > max_iters : break return sigma
short_docstring: Compute the level number variance of the current unfolded eigenvalues.
short_docstring_tokens: Compute the level number variance of the current unfolded eigenvalues .
comment: """Compute the level number variance of the current unfolded eigenvalues.
  
      Parameters
      ----------
      L: float
          The current L value to use for computation.
  
      tol: float
          Stop iterating when the last `min_iters` computed values of the
          level variance have a range (i.e. max - min) < tol
  
      max_iters: int
          Stop computing values for the level variance once max_iters values
          have been computed
  
      min_iters: int
          Minimum number of iterations
  
  
      Returns
      -------
      sigma: float
          The computed level variance for L.
  
      Notes
      -----
      Computes the level number variance by randomly selecting a point c in
      the interval [unfolded.min(), unfolded.max()], and counts the number
      of unfolded eigenvalues in (c - L/2, c + L/2) to determine a value for
      the level number variance, sigma(L). The process is repeated until the
      running averages stabilize, and the final running average is returned.
      """$SEP$# hold the last `size` running averages$SEP$# we'll use the fact that for x = [x_0, x_1, ... x_n-1], the$SEP$# average a_k == (k*a_(k-1) + x_k) / (k+1) for k = 0, ..., n-1