|
From: Yomi <gui...@gm...> - 2007-11-01 08:44:33
|
Hi,
I was trying to make the NonLeastSquare algorithm.
The results were not performing well using ConjugateGradient, so I have
decided to use LevenbergMarquardt instead.
To make it work, you need to update the LeastSquareFunction values member
function as follow:
Disposable<Array> LeastSquareFunction::values(const Array& x) const {
// size of target and function to fit vectors
Array target(lsp_.size()), fct2fit(lsp_.size());
// compute its values
lsp_.targetAndValue(x, target, fct2fit);
// do the difference
Array diff = (target - fct2fit)*(target - fct2fit);
return diff;
}
Of course don't forget to remove the definition from the class declaration.
After this, the results are very close from what I can get elsewhere.
Cheers
--
View this message in context: http://www.nabble.com/NonLeastSquare-with-LevenbergMarquardt%3A-small-code-update-tf4730027.html#a13525064
Sent from the quantlib-dev mailing list archive at Nabble.com.
|