Author: tlinnet Date: Wed Aug 27 14:23:41 2014 New Revision: 25337 URL: http://svn.gna.org/viewcvs/relax?rev=25337&view=rev Log: By using minfx, and the reported Jacobian, it is now possible to get the exact same error estimation as scipy.optimize.leastsq. The fatal error was to set the weighting matrix with diagonal elements as the error. There weights are 1/errors**2. There is though some un-answered questions left. The Jacobian used, is the direct derivative of the function. It is not the chi2 derivative Jacobian. task #7822(https://gna.org/task/index.php?7822): Implement user function to estimate R2eff and associated errors for exponential curve fitting. Modified: trunk/specific_analyses/relax_disp/estimate_r2eff.py Modified: trunk/specific_analyses/relax_disp/estimate_r2eff.py URL: http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/relax_disp/estimate_r2eff.py?rev=25337&r1=25336&r2=25337&view=diff ============================================================================== --- trunk/specific_analyses/relax_disp/estimate_r2eff.py (original) +++ trunk/specific_analyses/relax_disp/estimate_r2eff.py Wed Aug 27 14:23:41 2014 @@ -390,8 +390,7 @@ eye_mat = eye(self.errors.shape[0]) # Now form the error matrix, with errors down the diagonal. - #weights = self.errors**2 - weights = self.errors + weights = 1. / self.errors**2 W = multiply(weights, eye_mat) @@ -411,7 +410,7 @@ # 'minfx' # 'scipy.optimize.leastsq' -def estimate_r2eff(spin_id=None, ftol=1e-15, xtol=1e-15, maxfev=10000000, factor=100.0, method='minfx', verbosity=1): +def estimate_r2eff(method='scipy.optimize.leastsq', spin_id=None, ftol=1e-15, xtol=1e-15, maxfev=10000000, factor=100.0, verbosity=1): """Estimate r2eff and errors by exponential curve fitting with scipy.optimize.leastsq. scipy.optimize.leastsq is a wrapper around MINPACK's lmdif and lmder algorithms. @@ -427,6 +426,8 @@ Then solving initial guess by linear least squares of: ln(Intensity[j]) = ln(i0) - time[j]* r2eff. + @keyword method: The method to minimise and estimate errors. Options are: 'minfx' or 'scipy.optimize.leastsq'. + @type method: string @keyword spin_id: The spin identification string. @type spin_id: str @keyword ftol: The function tolerance for the relative error desired in the sum of squares, parsed to leastsq. @@ -437,8 +438,6 @@ @type maxfev: int @keyword factor: The initial step bound, parsed to leastsq. It determines the initial step bound (''factor * || diag * x||''). Should be in the interval (0.1, 100). @type factor: float - @keyword method: The method to minimise and estimate errors. Options are: 'scipy.optimize.leastsq' or 'minfx'. - @type method: string @keyword verbosity: The amount of information to print. The higher the value, the greater the verbosity. @type verbosity: int """