-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/corr matrix and inverse cov matrix as input in least squares function for correlated fits #223
Feature/corr matrix and inverse cov matrix as input in least squares function for correlated fits #223
Conversation
Hi Pia, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I have written a lot of text, not because I don't like your code but because I think we need a little bit of discussion concerning the capabilities of the routine with respect to the new parameters. Thanks again for starting this!
Hi,
I think that this is a good solution (I'll try to think more if I can come up with cases that are not covered). I have a few proposals for this strategy:
|
Hi Simon,
Just to be sure you meant to say correlation matrix? So you are happy with kwargs options I thinks it's a good idea to define
would not hold in the way you say. The Cholesky decomposition only works if positive definiteness holds but the condition number could still be large. I would still like to allow this so that if you are provided with an inverse covariance matrix (not unusual for cross-checking results) from someone else for instance you can still use it. We could just add in the description that the condition number should not be too large as you can also see from the function
Here you're referring to modified weights for single data points? So you would like to be able to hand over a list/dict of weights to this function?
Ok so this would be the same kwarg |
Hi,
I didn't fully get your next paragraph. Do you mean that one could also provide an inverted correlation matrix and then, in the fit routine, do the cholesky decomposition? I think the two steps do not necessarily commute but, as you write, this is probably more of an issue of the condition number is bad. If we would provide the routine to invert and decompose a matrix, which then can be passed to the fit routine, we would remain fully flexible, right? People could come up with a matrix of their choosing and use
I was wondering how to allow for modified weights for single data point, exactly. This would not go into the correlation matrix but into the "error vector". I am still a bit confused by all the possibilities... If we do not think about the expected chi^2, it would be fine to just be able to pass a correlation matrix, the "error vector" (something related to |
Hey @PiaLJP & @s-kuberski, any updates on this PR? Do you still want to proceed of should we close it for now? |
Hi, |
…utsourced the inversion & cholesky decomposition of the covariance matrix (function 'invert_corr_cov_cholesky(corr, covdiag)')
…ion and corrected its documentation
…squares documentation
… it) to sort correlation matrix according to a list of alphabetically sorted keys
…d typos in documentation of invert_corr_cov_cholesky()
Thanks a lot for the last changes. From my side, this can be merged. If you are fine with this @fjosw, I'll go ahead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
Added kwargs
corr_matrix
andinv_chol_cov_marix
to theleast_squares
function.Note: For the kwargs to work
correlated_fit=True
needs to be set too.(1) kwarg
corr_matrix
Now it is possible to hand over a correlation matrix of your own choosing for a correlated fit.
In the
least_squares
function a Cholesky decomposition is then applied to the correlation matrixand the resulting lower triangular matrix is then combined with the y errors and inverted such that
a lower triangular matrix corresponding to the inverse covariance matrix is extracted (and later used
for the definition of the correlated chi squared function).
(2) kwarg
inv_chol_cov_marix
It is also possible to hand over the inverse covariance matrix directly (as a lower triangular matrix)
if it has been constructed from a Cholesky decomposition of the correlation matrix in the same way
as detailed in (1).