-
Notifications
You must be signed in to change notification settings - Fork 12
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
Adaptive localization #168
Conversation
A first draft is ready:
Notes
|
The idea of rows matching the parameter group may not be great, but it was definitely not premature optimization as it made it possible to run adaptive localization on Troll in something resembling a reasonable amount of time. |
Overall I think this looks like a really nice and clean approach. |
I've also tried running it a bit with varying number of parameters and it seems to run amazingly fast! |
cov_XY[corr_XY < thres] = 0 # Set small values to zero | ||
# print(" Entries in cov_XY set to zero", np.isclose(cov_XY, 0).sum()) | ||
|
||
return X + cov_XY @ transition_matrix |
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.
This works.
Perhaps intuitively for others, because sample covariance among points does not include other variables.
Not intuitively for me, as I know that we may decompose our objective to cov_x @ LLS_coeff @ np.linalng.inv(cov_d)
. The LLS_coeff
should and does indeed change when removing variables. But this is captured by sample covariance cov_x
in the above, so the effect is removed.
So the above works.
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.
I must admit that I do not like this (mathematical) property.
But I do like the algorithmic exploitation of it in the code. 👍
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.
This works.
Here referring to that we do not have to recompute cov_XY
after variable removal / set to zero.
@kvashchuka, @dafeda and me had a whiteboard session (final result after some iterations is included). The hypothesis was to inspect the "transition matrix" in the code, let's call it What we think the problem, is that The original implementation of adaptive localization implicitly found a The batching algorithm sought subsets of In statistical terms, the marginal covariance is indeed the subsetted covariance directly, however this does not hold generally true for the inverse (precision) which we are working with. It holds true if the precision is diagonal, or if it is block-diagonal and we are subsetting the blocks. This should be equivalent to finding block |
Not sure I following everything. Let's have a chat! In the meantime, some notes:
The update equation for all parameters is: For a single parameter So The original implementation sliced the observations. Assume that parameter
I agree that this is something different, since |
The transition matrix depends on the parameters via the Y = g(X).
Indeed 👍 |
One of the great things about the KF is that it runs on Our measurement error is so independent so that we have even built it into the api I believe. At least for current practical purposes, Thus throwing something wild out there: how about iterating over observations assimilating them sequentially, and then iterate over parameters when doing this sequential update? for (dj, yj, Sigma_eps_j) in (observations, responses, variance):
H = LLS coefficients yj on X[mask,:] # 1xp but using X which could be p2xn for p2<p depending on mask
Sigma_yj = H @X @ X.T @ H.T # 1x1
Sigma_d = Sigma_yj + Sigma_eps_j # 1x1
for i in realizations
T_ji = (dj - yji) / Sigma_d # 1x1
for X_ki in realization_i_of_parameters:
if dj not masked for xk:
X_ki = X_ki + cov_xk_yj*T_ji Is this easily wrong? Or wrong for some other reason? I tried to adjust for the weird reasons that using the full transition matrix was wrong (writing Edit: If you do not have immediate objections (either theoretically or computationally) I could try implementing it for the Guass-Linear notebook example and see if results makes sense. |
Co-authored-by: Feda Curic <[email protected]>
…erative_ensemble_smoother into adaptive-localization
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.
This is great 👍
Playing around trying to come up with an API for adaptive localization.
BaseESMDA
handlesperturb_observations
and storing covariance and observations - this is common to both:ESMDA
, which inherits fromBaseESMDA
, complementing it withassimilate
.AdaptiveESMDA
, which also inherits fromBaseESMDA
, complementing it with its ownassimilate
method that also handles adaptive localization.Closes #167