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 N. 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. In
the case where and is a 2xN array, is
equivalent to .
y=None
x
linregress(x)
linregress(x[0],x[1])
Returns:
result : LinregressResult instance
The return value is an object with the following attributes:
slope : float
Slope of the regression line.
intercept : float
Intercept of the regression line.
rvalue : float
The Pearson correlation coefficient. The square of rvalue
is equal to the coefficient of determination.
pvalue : float
The 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. See alternative above for alternative
hypotheses.
stderr : float
Standard error of the estimated slope (gradient), under the
assumption of residual normality.
intercept_stderr : float
Standard error of the estimated intercept, under the assumption
of residual normality.
Notes
Missing values are considered pair-wise: if a value is missing in x,
the corresponding value in y is masked.
For compatibility with older versions of SciPy, the return value acts
like a namedtuple of length 5, with fields slope, intercept,
rvalue, pvalue and stderr, so one can continue to write:
slope,intercept,r,p,se=linregress(x,y)
With that style, however, the standard error of the intercept is not
available. To have access to all the computed values, including the
standard error of the intercept, use the return value as an object
with attributes, e.g.: