FAQ Database Discussion Community


print surface fit equation in python

python,numpy,matplotlib,scipy,least-squares
I'm trying to fit a surface model to a 3D data-set (x,y,z) using matplotlib. Where z = f(x,y). So, I'm going for the quadratic fitting with equation: f(x,y) = ax^2+by^2+cxy+dx+ey+f So far, I have successfully plotted the 3d-fitted-surface using least-square method using: # best-fit quadratic curve A = np.c_[np.ones(data.shape[0]), data[:,:2],...

how to solve many overdetermined systems of linear equations using vectorized codes?

multidimensional-array,scipy,vectorization,linear-algebra,least-squares
I need to solve a system of linear equations Lx=b, where x is always a vector (3x1 array), L is an Nx3 array, and b is an Nx1 vector. N usually ranges from 4 to something like 10. I have no problems solving this using scipy.linalg.lstsq(L,b) However, I need to...

Least squares for circle detection

python,algorithm,feature-detection,least-squares
I'm trying to perform a circle detection from a laser scan using least squares optimization over a subset of data points. Since the measurements are only obtained for a part of a circle, the least squares method returns faulty result, reporting a circle much closer to the laser than it...

How to solve for matrix in Matlab?

matlab,matrix,least-squares
How can I solve , where and and in the least squares sense in matlab? So I'd like to have the minimizing as output....

How to use least squares method in Matlab?

matlab,math,curve-fitting,least-squares,best-fit-curve
I have 37 linear equations and 36 variables in the form of a matrix equation; A*X=B . The equations don't have an exact answer. I want to use Matlab least square method to find the answers with the least error. I am new to Matlab so any comments will help....

Calculating 'hat' matrix in R

r,lm,least-squares
In calculating the 'hat' matrix in weighted least squares a part of the calculation is X^T*W*X However, I am unsure how one would do this in R See the following example: x <- matrix(c(1,2,3,4,5,6),nrow=3,ncol=2,byrow=T) xt <- t(x) w <- as.vector(c(7,8,9)) xt*w%*%x Which gives the error: Error in xt * w...

MATLAB polynomial fit selective powers

matlab,least-squares,polynomials
I have 2 vectors x and y to which I want to fit a polynomial as y = f(x) in MATLAB. I could have used polyfit. However, I want to fit only selective power terms of the polynomial. For example, y = f(x) = a*x^3 + b*x + c. Notice...

least-squares method with a constraint

matlab,math,curve-fitting,linear-programming,least-squares
I have 37 linear equations with 36 variables in the form of matrix: A x = b. (A has 37 rows and 36 columns.) The equations don't have an exact solution so I have used Matlab to find the closest answer using x = A \ b. The problem is...