code: def linregress(x, y=None):
      """
      Calculate a linear least-squares regression for two sets of measurements.
  
      Parameters
      ----------
      x, y : array_like
          Two sets of measurements.  Both arrays should have the same length.
          If only x is given (and y=None), then it must be a two-dimensional
          array where one dimension has length 2.  The two sets of measurements
          are then found by splitting the array along the length-2 dimension.
  
      Returns
      -------
      slope : float
          slope of the regression line
      intercept : float
          intercept of the regression line
      rvalue : float
          correlation coefficient
      pvalue : float
          two-sided p-value for a hypothesis test whose null hypothesis is
          that the slope is zero, using Wald Test with t-distribution of
          the test statistic.
      stderr : float
          Standard error of the estimated gradient.
  
      See also
      --------
      :func:`scipy.optimize.curve_fit` : Use non-linear
       least squares to fit a function to data.
      :func:`scipy.optimize.leastsq` : Minimize the sum of
       squares of a set of equations.
  
      Examples
      --------
      >>> import matplotlib.pyplot as plt
      >>> from scipy import stats
  
      Generate some data:
  
      >>> np.random.seed(12345678)
      >>> x = np.random.random(10)
      >>> y = 1.6*x + np.random.random(10)
  
      Perform the linear regression:
  
      >>> slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)
      >>> print("slope: %f    intercept: %f" % (slope, intercept))
      slope: 1.944864    intercept: 0.268578
  
      To get coefficient of determination (r_squared):
  
      >>> print("r-squared: %f" % r_value**2)
      r-squared: 0.735498
  
      Plot the data along with the fitted line:
  
      >>> plt.plot(x, y, 'o', label='original data')
      >>> plt.plot(x, intercept + slope*x, 'r', label='fitted line')
      >>> plt.legend()
      >>> plt.show()
  
      """
      TINY = 1.0e-20
      if y is None:  # x is a (2, N) or (N, 2) shaped array_like
          x = np.asarray(x)
          if x.shape[0] == 2:
              x, y = x
          elif x.shape[1] == 2:
              x, y = x.T
          else:
              msg = (
                  "If only `x` is given as input, it has to be of shape "
                  "(2, N) or (N, 2), provided shape was %s"
                  % str(x.shape)
              )
              raise ValueError(msg)
      else:
          x = np.asarray(x)
          y = np.asarray(y)
  
      if x.size == 0 or y.size == 0:
          raise ValueError("Inputs must not be empty.")
  
      n = len(x)
      xmean = np.mean(x, None)
      ymean = np.mean(y, None)
  
      # average sum of squares:
      ssxm, ssxym, ssyxm, ssym = np.cov(x, y, bias=1).flat
      r_num = ssxym
      r_den = np.sqrt(ssxm * ssym)
      if r_den == 0.0:
          r = 0.0
      else:
          r = r_num / r_den
          # test for numerical error propagation
          if r > 1.0:
              r = 1.0
          elif r < -1.0:
              r = -1.0
  
      df = n - 2
      slope = r_num / ssxm
      intercept = ymean - slope * xmean
      if n == 2:
          # handle case when only two points are passed in
          if y[0] == y[1]:
              prob = 1.0
          else:
              prob = 0.0
          sterrest = 0.0
      else:
          t = r * np.sqrt(df / ((1.0 - r + TINY) * (1.0 + r + TINY)))
          prob = 2 * distributions.t.sf(np.abs(t), df)
          sterrest = np.sqrt((1 - r**2) * ssym / ssxm / df)
  
      return LinregressResult(slope, intercept, r, prob, sterrest)
  
imports: from collections import namedtuple
  import numpy
  from .None import distributions
label_desc: Use image node_id 1 for calling a global function with example usage: linregress(x, y) and returns: LinregressResult