least-squares

Fit points to a plane algorithms, how to iterpret results?

心不动则不痛 提交于 2019-11-30 09:06:48
Update : I have modified the Optimize and Eigen and Solve methods to reflect changes. All now return the "same" vector allowing for machine precision. I am still stumped on the Eigen method. Specifically How/Why I select slice of the eigenvector does not make sense. It was just trial and error till the normal matched the other solutions. If anyone can correct/explain what I really should do, or why what I have done works I would appreciate it. . Thanks Alexander Kramer, for explaining why I take a slice, only alowed to select one correct answer I have a depth image. I want to calculate a crude

Python / Scipy - implementing optimize.curve_fit 's sigma into optimize.leastsq

北城以北 提交于 2019-11-30 05:20:03
问题 I am fitting data points using a logistic model. As I sometimes have data with a ydata error, I first used curve_fit and its sigma argument to include my individual standard deviations in the fit. Now I switched to leastsq, because I needed also some Goodness of Fit estimation that curve_fit could not provide. Everything works well, but now I miss the possibility to weigh the least sqares as "sigma" does with curve_fit. Has someone some code example as to how I could weight the least squares

Partial Least Squares Library

时间秒杀一切 提交于 2019-11-30 03:44:50
There was already a question like this, but it was not answered, so I try to post it again. Does anyone know of an open-source implementation of a partial least squares algorithm in C++ (or C)? Or maybe a library that does it? FastPLS is a library that provides a C/C++ and MATLAB interface for speeding up partial least squares. Its author is Balaji Vasan Srinivasan. The author worked under the supervision of Professor Ramani Duraiswami at the University of Maryland, College Park, MD, USA. Partial Least Squares and Generalized Partial Least Squares models based on NIPALS algorithm . implement

Non-linear Least Squares Optimization Library for C [closed]

限于喜欢 提交于 2019-11-29 22:30:11
I'm looking for a library in C that will do optimization of an objective function (preferrably Levenberg-Marquardt algorithm) and will support box constraints, linear inequality constraints and non-linear inequality constraints. I've tried several libraries already, but none of them do employ the necessary constraint types for my application: GNU GSL (does not support constraints at all) cMPFIT (only supports box constraints) levmar (does not support non-linear constraints at all) I am currently exploring NLopt , but I'm not sure if I can achieve a least-squares approach with any of the

Graphing perpendicular offsets in a least squares regression plot in R

倾然丶 夕夏残阳落幕 提交于 2019-11-29 21:05:57
I'm interested in making a plot with a least squares regression line and line segments connecting the datapoints to the regression line as illustrated here in the graphic called perpendicular offsets: http://mathworld.wolfram.com/LeastSquaresFitting.html (from MathWorld - A Wolfram Web Resource: wolfram.com ) I have the plot and regression line done here: ## Dataset from http://www.apsnet.org/education/advancedplantpath/topics/RModules/doc1/04_Linear_regression.html ## Disease severity as a function of temperature # Response variable, disease severity diseasesev<-c(1.9,3.1,3.3,4.8,5.3,6.1,6.4

Calculating the null space of a matrix

Deadly 提交于 2019-11-29 13:26:59
问题 I'm attempting to solve a set of equations of the form Ax = 0. A is known 6x6 matrix and I've written the below code using SVD to get the vector x which works to a certain extent. The answer is approximately correct but not good enough to be useful to me, how can I improve the precision of the calculation? Lowering eps below 1.e-4 causes the function to fail. from numpy.linalg import * from numpy import * A = matrix([[0.624010149127497 ,0.020915658603923 ,0.838082638087629 ,62.0778180312547 ,

Weighted trendline

旧街凉风 提交于 2019-11-29 02:04:00
Excel produces scatter diagrams for sets of pair values. It also gives the option of producing a best fit trendline and formula for the trendline. It also produces bubble diagrams which take into consideration a weight provided with each value. However, the weight has no influence on the trendline or formula. Here is an example set of values, with their mappings and weights. Value Map Weight 0 1 10 1 2 10 2 5 10 3 5 20 4 6 20 5 1 1 With Excel's trendline, the mapping for value 5 has too much influence on the formula. Is there any way to produce a formula that reflects the respective weights?

Partial Least Squares Library

主宰稳场 提交于 2019-11-29 00:48:31
问题 There was already a question like this, but it was not answered, so I try to post it again. Does anyone know of an open-source implementation of a partial least squares algorithm in C++ (or C)? Or maybe a library that does it? 回答1: FastPLS is a library that provides a C/C++ and MATLAB interface for speeding up partial least squares. Its author is Balaji Vasan Srinivasan. The author worked under the supervision of Professor Ramani Duraiswami at the University of Maryland, College Park, MD, USA

How to calculate variance of least squares estimator using QR decomposition in R?

♀尐吖头ヾ 提交于 2019-11-29 00:18:16
I'm trying to learn QR decomposition, but can't figure out how to get the variance of beta_hat without resorting to traditional matrix calculations. I'm practising with the iris data set, and here's what I have so far: y<-(iris$Sepal.Length) x<-(iris$Sepal.Width) X<-cbind(1,x) n<-nrow(X) p<-ncol(X) qr.X<-qr(X) b<-(t(qr.Q(qr.X)) %*% y)[1:p] R<-qr.R(qr.X) beta<-as.vector(backsolve(R,b)) res<-as.vector(y-X %*% beta) Thanks for your help! setup (copying in your code) y <- iris$Sepal.Length x <- iris$Sepal.Width X <- cbind(1,x) n <- nrow(X) p <- ncol(X) qr.X <- qr(X) b <- (t(qr.Q(qr.X)) %*% y)[1:p]

Finding translation and scale on two sets of points to get least square error in their distance?

人盡茶涼 提交于 2019-11-28 17:19:44
I have two sets of 3D points (original and reconstructed) and correspondence information about pairs - which point from one set represents the second one. I need to find 3D translation and scaling factor which transforms reconstruct set so the sum of square distances would be least (rotation would be nice too, but points are rotated similarly, so this is not main priority and might be omitted in sake of simplicity and speed). And so my question is - is this solved and available somewhere on the Internet? Personally, I would use least square method, but I don't have much time (and although I'm