Hi,
Optimization problem:
The model is a superconducting flux qubit, which essentially is a Hamiltonian (60x60 Hermitian matrix) that is constructed and diagonalized to get first two eigenenergies. Then these two eigenenergies are asked to be fit to some experimental data to find the qubit parameters (that are used to construct the Hamiltonian).
Solving the optimization problem:
I use 'nelder' method and have installed . I can find my system parameters for a variety of input data, and I have also numdifftools to calculate covariance matrix of the fit result. I can solve the optimization problem for a variety of data, and it converges and yields reasonable parameter errors.
Error encountered:
For some sets of data (which I'm not sure what is unique about them) I can find the optimal fitting parameters when calc_covar=False, but when calc_covar=False I get the following errors at the end:
invalid value encountered in sqrt par.stderr = sqrt(self.result.covar[ivar, ivar])
invalid value encountered in sqrt (par.stderr * sqrt(self.result.covar[jvar, jvar])))
The minimizer gives the same result as the case when calc_covar=False, but when it tries to calculate them it gives this error. Again this does not occur on all my data, but only some
Main problem:
When looking at MinimizerResult.covar, I see that the covariance matrix has negative elements on the diagonal, which is the culprit. I'm not sure how covariance matrix is calculated in your code, but it should always have positive diagonals, as the diagonal elements are sigma**2 and can not be negative. This is the main problem that I wanted to discuss and would appreciate if you could elaborate.
Unfortunately the code that produces this error is extremely lengthy, and when I tried to reproduce this problem with some simpler models and data to post here I failed. However I guess you just need to check for positivity of the diagonal elements of the covariance matrix, and hopefully nothing fancier should be done.
Thanks for you amazing and user-friendly package.
Cheers,
Mostafa