A very late reply, but just in case someone needs a ready function for this:
scipy.stats.linregress
i.e.
slope, intercept, r_value, p_value, std_err = scipy.stats.linregress(x, y)
as in @Adam Marples’s answer.
Related Contents:
- Fitting empirical distribution to theoretical ones with Scipy (Python)?
- How to do exponential and logarithmic curve fitting in Python? I found only polynomial fitting
- Compute a confidence interval from sample data
- python numpy/scipy curve fitting
- How to normalize a NumPy array to a unit vector?
- Multiple linear regression in Python
- How do I fit a sine curve to my data with pylab and numpy?
- Why do “Not a Number” values equal True when cast as boolean in Python/Numpy?
- Calculating Pearson correlation and significance in Python
- How can I use numpy.correlate to do autocorrelation?
- How to plot empirical cdf (ecdf)
- Fitting a closed curve to a set of points
- How to apply piecewise linear fit in Python?
- How do I compute derivative using Numpy?
- How to make scipy.interpolate give an extrapolated result beyond the input range?
- How do I calculate percentiles with python/numpy?
- numpy max vs amax vs maximum
- scipy curve_fit doesn’t like math module
- Efficiently detect sign-changes in python
- numpy arbitrary precision linear algebra
- Linear regression with matplotlib / numpy
- Fitting a line in 3D
- fitting data with numpy
- Equivalent of `polyfit` for a 2D polynomial in Python
- plotting a histogram on a Log scale with Matplotlib
- Linear regression of arrays containing NANs in Python/Numpy
- How to calculate the statistics “t-test” with numpy
- What’s the simplest way to extend a numpy array in 2 dimensions?
- How can the Euclidean distance be calculated with NumPy?
- Sieve of Eratosthenes – Finding Primes Python
- Performance of Pandas apply vs np.vectorize to create new column from existing columns
- efficiently convert uneven list of lists to minimal containing array padded with nan
- How to calculate the sum of all columns of a 2D numpy array (efficiently)
- ImportError in importing from sklearn: cannot import name check_build
- Find matching rows in 2 dimensional numpy array
- Difference between the built-in pow() and math.pow() for floats, in Python?
- How can I attach a pyplot function to a figure instance?
- Is there a numpy builtin to reject outliers from a list
- What does “three dots” in Python mean when indexing what looks like a number?
- Is there a multi-dimensional version of arange/linspace in numpy?
- Element-wise string concatenation in numpy
- Subsetting a 2D numpy array
- Weighted percentile using numpy
- Set values on the diagonal of pandas.DataFrame
- Why does numpy std() give a different result to matlab std()?
- NumPy array/matrix of mixed types
- How to convert list of numpy arrays into single numpy array?
- How do I pass large numpy arrays between python subprocesses without saving to disk?
- How to change array shapes in in numpy?
- Fitting a Weibull distribution using Scipy