I am attempting to fit a version of the Hikami-Larkin-Nagaoka expression to a set of data which involves 2 digamma functions and a natural logarithm:
B is the independent variable, the fitting parameters I take to be t_phi, t_e and D, and the rest are constants.
An attempt at a fitting results in a "NaN values detected" type of error (full traceback below). I tried tweaking the starting values of the parameters as well as simplifying the formula. I notice that removing the logarithmic term removes the NaN error but then t_phi and t_e remain stuck at their original values. The whole expression evaluates to approx. 8e-05 and the logarithm evaluates to approx. 6.9, when taking the initial values of the parameters (I had a look at the NaN section in the FAQ).
I would appreciate any suggestions that you may have to deal with the NaN error and/or possibly obtain a fit of the data.
I include a link to a file with the data, the code and a full traceback below.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-20-14c0825f71c7> in <module>
28
29 # The fitting
---> 30 result = Minimizer(HLN, params, fcn_args=(B, mcond)).minimize()
31
32 # The final result
~\anaconda3\lib\site-packages\lmfit\minimizer.py in minimize(self, method, params, **kws)
2361 val.lower().startswith(user_method)):
2362 kwargs['method'] = val
-> 2363 return function(**kwargs)
2364
2365
~\anaconda3\lib\site-packages\lmfit\minimizer.py in leastsq(self, params, max_nfev, **kws)
1698 result.call_kws = lskws
1699 try:
-> 1700 lsout = scipy_leastsq(self.__residual, variables, **lskws)
1701 except AbortFitException:
1702 pass
~\anaconda3\lib\site-packages\scipy\optimize\minpack.py in leastsq(func, x0, args, Dfun, full_output, col_deriv, ftol, xtol, gtol, maxfev, epsfcn, factor, diag)
420 if maxfev == 0:
421 maxfev = 200*(n + 1)
--> 422 retval = _minpack._lmdif(func, x0, args, full_output, ftol, xtol,
423 gtol, maxfev, epsfcn, factor, diag)
424 else:
~\anaconda3\lib\site-packages\lmfit\minimizer.py in __residual(self, fvars, apply_bounds_transformation)
602 raise AbortFitException("fit aborted by user.")
603 else:
--> 604 return _nan_policy(np.asarray(out).ravel(),
605 nan_policy=self.nan_policy)
606
~\anaconda3\lib\site-packages\lmfit\minimizer.py in _nan_policy(arr, nan_policy, handle_inf)
2445 'handle this! Please read
https://lmfit.github.io/lmfit-py/faq.html#i-get-errors-from-nan-in-my-fit-what-can-i-do '
2446 'for more information.')
-> 2447 raise ValueError(msg)
2448 return arr
2449
ValueError: NaN values detected in your input data or the output of your objective/model function - fitting algorithms cannot handle this! Please read
https://lmfit.github.io/lmfit-py/faq.html#i-get-errors-from-nan-in-my-fit-what-can-i-do for more information.