Questions tagged [least-squares]

Refers to a general estimation technique that selects the parameter value to minimize the squared difference between two quantities, such as the observed value of a variable, and the expected value of that observation conditioned on the parameter value. Questions about the theory behind least-squares should utilize the Cross Validated (https://stats.stackexchange.com/questions) Stack Exchange site.

Overview

From the "Least squares" article on Wikipedia:

The method of least squares is a standard approach to the approximate solution of overdetermined systems, i.e., sets of equations in which there are more equations than unknowns. "Least squares" means that the overall solution minimizes the sum of the squares of the errors made in the results of every single equation.

Least squares problems fall into two categories: linear or ordinary least squares and non-linear least squares, depending on whether or not the residuals are linear in all unknowns. The linear least-squares problem occurs in statistical regression analysis; it has a closed-form solution. A closed-form solution (or closed-form expression) is any formula that can be evaluated in a finite number of standard operations. The non-linear problem has no closed-form solution and is usually solved by iterative refinement; at each iteration the system is approximated by a linear one, and thus the core calculation is similar in both cases.

Other References

Least squares methods are treated in many introductory statistics resources and textbooks, but there are also advanced resources dedicated only to the subject, for example:

Tag usage

Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

1013 questions
0
votes
1 answer

Least square approximation for straight line fit (normal form)

I am doing a straight line best fit for certain data set. I am using the normal form of straight line. Suppose I have a set of points (x_1,y_1), (x_2,y_2), ... , (x_n,y_n). Suppose the normal form of a straight line is x*cos(theta) + y*sin(theta) =…
ayan.c
  • 263
  • 2
  • 7
  • 17
0
votes
2 answers

Curve Fit 5 points

I am trying to curve fit 5 points in C. I have used this code from a previous post (Can sombody simplify this equation for me?) to do 4 points, but now I need to add another point. // Input data: arrays x[] and y[] // x[1],x[2],x[3],x[4] - X…
0
votes
1 answer

Python LeastSquares plot

I have to draw plot using least squares method in Python 3. I have list of x and y values: y = [186,273,308,484] x = [2.25,2.34,2.47,2.56] There are many more values for x and for y, there is only a shortcut. And now, I know, that f(x)=y should…
0
votes
1 answer

how to do a multi dimensional function fitting using python

I am doing some least square fitting things. and it's two dimensional which means (x1i,x2i)-->(yi).So far i checked a lot online documents which are designed for 1 dimensional (xi)->(yi). 1 So anyone knows how to solve multi-dimensional least…
baozi
  • 679
  • 10
  • 30
0
votes
1 answer

least square approximation: how this matrix calculation equation is deducted?

I am reading a book "kernel methods for pattern analysis". For the least square approximation, it is to minimise the sum of the square of the discrepancies: e=y-Xw Therefore it is to minimize L(w,S)=(y-Xw)'(y-Xw) Leading to $$ w=(X'X)^-1 X'y $$ I…
CyberPlayerOne
  • 3,078
  • 5
  • 30
  • 51
0
votes
1 answer

estimateRigidTransform in OpenCV

I am using estimateRigidTransform in OpenCV to get the rigid transform matrix but i do not know how estimateRigidTransform get the rigid transform matrix Does estimateRigidTransform use the Least squares Algorithm ?
Moore liu
  • 31
  • 1
  • 8
0
votes
1 answer

How to get the error on the parameter using least squares fit in scipy

I have used the least squares fit in the scipy.optimize package and was wondering what the second argument that is returned is?
0
votes
3 answers

Parameters estimation on Lotka Volterra model with Scilab

I'm trying to make a parameters estimation on Lotka-Volterra model with Scilab (I am a total neophyte). When I try to run the script, Scilab warns about incoherent subtraction. I guess my problem is the same as in this topic, but the solution there…
Wendac
  • 11
  • 4
0
votes
1 answer

EJML least squares

I am trying to have the least squares computed for an over determined system. DenseMatrix64F D_dense = RandomMatrices.createRandom(dimension, 3 * dimension, -1, 1, r); D1 = SimpleMatrix.wrap(D1).transpose().getMatrix(); LinearSolver
Fabio Oesch
  • 143
  • 2
  • 11
0
votes
1 answer

lmfit -py using arrays for parameter optimization

Situation: I'm trying to optimise parameters for a natural creek where gases degas or ingas at a certain rate according to reasonably well established equations. We have the measured concentrations at certain distances downstream and would like to…
Oregano
  • 134
  • 2
  • 12
0
votes
1 answer

piece-wise linear curve fitting with MATLAB

In my experiment, I need to approximate or fitting a measurement y = f_m(x) with n linear segments. Value of n can be selected to be 1, 2, 3, 4, 5... and probably less than 10. For clarity, it's good if the errors from different cases can be…
TSL_
  • 2,049
  • 3
  • 34
  • 55
0
votes
1 answer

'args not defined' error from leastsq function

I tried fitting a function to data from a matrix synthData in the form of arrays synthData[0,:], synthData[1,:], and the y-values synthData[2,:]. But the following snippet returns "name 'args' not defined" guess = [16.200000, -0.700000, 5.900000,…
user3133865
  • 205
  • 1
  • 2
  • 4
0
votes
1 answer

least squares minimisation fortran 77

Trying to get a one-parameter least squares minimisation working in fortran77. Here's the code; it compiles and seems to work except....it gets caught in an infinite loop between values of h1= 1.8E-2 and 3.5E-2. Having a look now but, odds are, I'm…
user3228501
  • 1
  • 1
  • 4
0
votes
1 answer

Find approximation of sine using least squares

I am doing a project where i find an approximation of the Sine function, using the Least Squares method. Also i can use 12 values of my own choice.Since i couldn't figure out how to solve it i thought of using Taylor's series for Sine and then…
M.Achilles
  • 93
  • 1
  • 2
  • 10
0
votes
1 answer

Numpy Leastsq fitting returning unchanged inital guess in all cases

I am attempting to fit a function using Leastsq to fit to a few relevant points in an fft. The issue at hand is that, no matter how good or bad the fit is, there is absolutely no change in the parameters. In other words the least squares takes 6…
Elliot
  • 5,211
  • 10
  • 42
  • 70