code: def linreg(close, length=None, offset=None, **kwargs):
      """Indicator: Linear Regression"""
      # Validate arguments
      length = int(length) if length and length > 0 else 14
      close = verify_series(close, length)
      offset = get_offset(offset)
      angle = kwargs.pop("angle", False)
      intercept = kwargs.pop("intercept", False)
      degrees = kwargs.pop("degrees", False)
      r = kwargs.pop("r", False)
      slope = kwargs.pop("slope", False)
      tsf = kwargs.pop("tsf", False)
  
      if close is None:
          return
  
      # Calculate Result
      x = range(
          1, length + 1
      )  # [1, 2, ..., n] from 1 to n keeps Sum(xy) low
      x_sum = 0.5 * length * (length + 1)
      x2_sum = x_sum * (2 * length + 1) / 3
      divisor = length * x2_sum - x_sum * x_sum
  
      def linear_regression(series):
          y_sum = series.sum()
          xy_sum = (x * series).sum()
  
          m = (length * xy_sum - x_sum * y_sum) / divisor
          if slope:
              return m
          b = (y_sum * x2_sum - x_sum * xy_sum) / divisor
          if intercept:
              return b
  
          if angle:
              theta = npAtan(m)
              if degrees:
                  theta *= 180 / npPi
              return theta
  
          if r:
              y2_sum = (series * series).sum()
              rn = length * xy_sum - x_sum * y_sum
              rd = (divisor * (length * y2_sum - y_sum * y_sum)) ** 0.5
              return rn / rd
  
          return m * length + b if tsf else m * (length - 1) + b
  
      def rolling_window(array, length):
          """https://github.com/twopirllc/pandas-ta/issues/285"""
          strides = array.strides + (array.strides[-1],)
          shape = array.shape[:-1] + (
              array.shape[-1] - length + 1,
              length,
          )
          return as_strided(array, shape=shape, strides=strides)
  
      if npVersion >= "1.20.0":
          from numpy.lib.stride_tricks import sliding_window_view
  
          linreg_ = [
              linear_regression(_)
              for _ in sliding_window_view(npArray(close), length)
          ]
      else:
          from numpy.lib.stride_tricks import as_strided
  
          linreg_ = [
              linear_regression(_)
              for _ in rolling_window(npArray(close), length)
          ]
  
      linreg = Series(
          [npNaN] * (length - 1) + linreg_, index=close.index
      )
  
      # Offset
      if offset != 0:
          linreg = linreg.shift(offset)
  
      # Handle fills
      if "fillna" in kwargs:
          linreg.fillna(kwargs["fillna"], inplace=True)
      if "fill_method" in kwargs:
          linreg.fillna(method=kwargs["fill_method"], inplace=True)
  
      # Name and Categorize it
      linreg.name = f"LR"
      if slope:
          linreg.name += "m"
      if intercept:
          linreg.name += "b"
      if angle:
          linreg.name += "a"
      if r:
          linreg.name += "r"
  
      linreg.name += f"_{length}"
      linreg.category = "overlap"
  
      return linreg
  
file_path: pandas-ta/pandas_ta/overlap/linreg.py
imports: from numpy import array
  from numpy import arctan
  from numpy import nan
  from numpy import pi
  from numpy.version import version
  from pandas import Series
  from pandas_ta.utils import get_offset, verify_series
label_desc: Use image node_id 1 for calling a global function with example usage: linreg(close, length, offset) and returns: linreg, unknown, as_strided, m, b, theta, unknown