lessthanoptimal / ddogleg

Java numerics library for optimization, polynomial root finding, sorting, robust model fitting, and more.
http://ddogleg.org
49 stars 18 forks source link

weighted least squares #4

Closed davidmoten closed 7 years ago

davidmoten commented 7 years ago

Hi, thanks for the library. I wondering if by some minor modification to the code I can introduce a variable weight into the least squares cost function. I'm new to Levenberg-Marquandt etc algorithms but to do non-linear regression where the points have varying error I'm planning on weighting the least-squares components with 1/variance. Do you think this might work via a simple code change and where would that change be made? Thanks!

lessthanoptimal commented 7 years ago

This should be easy to implement in your code actually. You will compute and return f(i)-f'(i) instead return (f(i)-f'(i))/stdev[i] This actually might be good as an example.

davidmoten commented 7 years ago

Great to hear. Nice that we have the ability to supply f(i)-f'(i). I'll let you know how I'm going with this as it might make an interesting example. It`s to do with beacon detections by satellites in a search and rescue scenario. I'll try not to complicate your world but I might get your opinion on whatever approach I come up with if that's alright. Cheers.