Skip to content
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

Writeup of posterior properties #2699

Merged
merged 1 commit into from
Jan 13, 2022

Conversation

Blunde1
Copy link
Contributor

@Blunde1 Blunde1 commented Jan 12, 2022

Issue
Resolves #2660

Approach
Using equations from Evensen with slightly modified notation (perhaps should be changed), introduce updating equations and discuss the properties that these leads to.
The properties are directly used in the code in tests for the updating module.
Implemented in #2628 and #2697

@Blunde1 Blunde1 self-assigned this Jan 12, 2022
@Blunde1 Blunde1 requested a review from dafeda January 12, 2022 10:34

The updating from the prior :math:`p(\psi)=N\left(\mu_\psi,\Sigma_\psi\right)`
to the posterior :math:`p(\psi|d)=N\left(\mu_{\psi|d},\Sigma_{\psi|d}\right)`, assimilating measurements :math:`d`,
linear in :math:`\psi` is performed by the Kalman methods by employing the following equations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "linear in :math:\psi"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the measurements d, so the comma should perhaps be after psi? Suggestion: it could be made more clear by: ... assimilating measurements d that are linear in psi, is performed...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better I think.

K = \Sigma_{\psi}M^\top (M\Sigma_{\psi}M^\top + \Sigma_{d})^{-1}
\end{align}

is called tha Kalman gain, and :math:`M` is the linear measurement matrix, so that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a matrix be non-linear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It cannot! How about saying linear measurement operator (i.e., a matrix) (I think this is almost exactly what Evensen says)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's nice


is the best estimate of :math:`d` under the prior knowledge, and the error is assumed Gaussian with covariance :math:`\Sigma_d`.
The ensemble variants draw an :math:`N`-sample :math:`\{\psi\}_{i=1}^N` from the prior,
and perturbs observations :math:`d` using the distributions of measurements creating a corresponding observation-sample :math:`\{d\}_{i=1}^N`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "...and perturb", I think.


where the estimated Kalman gain :math:`\hat{K}` is found by exchanging the prior covariance with an estimate based on its sample.
Thus, the ensemble methods combine a sample from the prior with a sample from the likelihood of observed data, to form a new sample from the posterior.
The posterior distribution that the posterior sample is conseptually sampled from, has mean and covariance found by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conceptually

\hat{\mu}_{ml} = \arg\min_{\mu} |d-M\mu|_2
\end{align}

Furthermore, for a monotone sequence in belief in measurements, a monotone sequence
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a bit of a hard time parsing this sentence.

What if we write the following instead:

Furthermore, for a strictly decreasing sequence in belief in measurements, we expect the distance between the posterior and the maximum likelihood estimate to be strictly decreasing as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the suggestion, except for the words "we expect". It either makes it sound like it is some stochastic convergence with an expectation so and so, or that we are not certain. How about skipping "we expect", and adding "... estimate will be strictly decreasing ..." later on?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what happens when you say expect to a statistician...

"will be strictly decreasing" is nice,.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other day some friends discussed if they wanted pass/fail or graded exams. They concluded that it was dependent on expected grades and the existing GPA of past exams. For the case of perfect GPA, they said it did not matter as long as the expected grade was perfect. I pointed out that the only way the actual expectation is the perfect grade, is if other grades have zero probability, and thus, you not only feel and expect that you will get a perfect grade but you are certain with zero variation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I make parties fun 🎈


- For the posterior estimate, we require that

a. The information in :math:`d` has been assimilated, creating a better estimate, so that :math:`|\hat{\mu}_{\psi|d}-\hat{\mu}_{ml}|_2<|\hat{\mu}_{\psi}-\hat{\mu}_{ml}|_2` and :math:`|\hat{\mu}_{\psi|d}-\hat{\psi}_{\psi}|_2<|\hat{\mu}_{\psi}-\hat{\mu}_{ml}|_2`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does

:math:`|\hat{\mu}{\psi|d}-\hat{\psi}{\psi}|_2

represent the distance between the assimilated mean and the prior mean?
Not sure about the notation \hat{\psi}_{\psi}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a typo! It should be the prior sample expectation-estimate, so \hat{\mu}_{\psi}


In ert, the exact moments of the posterior is not calculated, as information is passed along only through the updated sample.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "..are not calculated"

In ert, the exact moments of the posterior is not calculated, as information is passed along only through the updated sample.
However, because the perturbations are guaranteed to sum to zero, the posterior sample inherits the exact posterior expectation as its sample mean,
and as a consequence, the maximum likelihood estimate is preserved.
This guarantees the path of the posterior estimate as above.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As below?

@dafeda
Copy link
Contributor

dafeda commented Jan 12, 2022

Perhaps we should add a link to this in test_update.cpp?


a. We become more certain of our estimates as informative data is assimilated, thus :math:`0<\det(\Sigma_{\psi|d})<\det(\Sigma_{\psi})`.
b. We become increasingly certain in our estimates when increasingly informative data is assimilated: When a sequence of :math:`\sigma_d` decreases strictly, then so will the corresponding sequence of :math:`\det(\Sigma_{\psi|d})`.
c. The certainty of our estimate does not move from the priors, when assimilated data contains no information: When :math:`\sigma_d\to \infty` then :math:`\det(\Sigma_{\psi|d})\to\det(\Sigma_{\psi})` from below.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think comma before "when" can be removed to improve flow.
Yeah I know, overly pedantic :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pedantic is good, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to update this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬

a. We become more certain of our estimates as informative data is assimilated, thus :math:`0<\det(\Sigma_{\psi|d})<\det(\Sigma_{\psi})`.
b. We become increasingly certain in our estimates when increasingly informative data is assimilated: When a sequence of :math:`\sigma_d` decreases strictly, then so will the corresponding sequence of :math:`\det(\Sigma_{\psi|d})`.
c. The certainty of our estimate does not move from the priors, when assimilated data contains no information: When :math:`\sigma_d\to \infty` then :math:`\det(\Sigma_{\psi|d})\to\det(\Sigma_{\psi})` from below.
d. If assimilated data is perfect without noise, then we are fully certain of the posterior estiamte: When :math:`\sigma_d\to 0` then :math:`\det(\Sigma_{\psi|d})\to 0` from above.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit clearer:

"If assimilated data is perfect, i.e., without noise, then ..."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to update this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 should be updated now!

@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2022

Codecov Report

Merging #2699 (6d4c4a0) into main (1d0d310) will increase coverage by 3.80%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2699      +/-   ##
==========================================
+ Coverage   61.24%   65.04%   +3.80%     
==========================================
  Files         341      651     +310     
  Lines       36647    53907   +17260     
  Branches     4610     4610              
==========================================
+ Hits        22444    35065   +12621     
- Misses      12722    17360    +4638     
- Partials     1481     1482       +1     
Impacted Files Coverage Δ
libres/lib/enkf/block_fs_driver.cpp 81.35% <0.00%> (-0.57%) ⬇️
libres/lib/res_util/block_fs.cpp 53.08% <0.00%> (ø)
ert_shared/cli/workflow.py 68.75% <0.00%> (ø)
ert_gui/tools/plugins/plugin_runner.py 26.66% <0.00%> (ø)
ert_data/measured.py 87.37% <0.00%> (ø)
ert_gui/ertwidgets/models/all_cases_model.py 33.33% <0.00%> (ø)
ert3/config/_experiment_config.py 98.80% <0.00%> (ø)
ert_shared/dark_storage/graphql/__init__.py 96.42% <0.00%> (ø)
ert_gui/model/node.py 85.18% <0.00%> (ø)
ert_gui/ide/wizards/__init__.py 100.00% <0.00%> (ø)
... and 319 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d0d310...6d4c4a0. Read the comment docs.

@Blunde1
Copy link
Contributor Author

Blunde1 commented Jan 12, 2022

Perhaps we should add a link to this in test_update.cpp?

I agree. Does such a reference go at the top of the file, or somewhere else?

@dafeda
Copy link
Contributor

dafeda commented Jan 13, 2022

Perhaps we should add a link to this in test_update.cpp?

I agree. Does such a reference go at the top of the file, or somewhere else?

I'd put it in a docstring after the #includes

Copy link
Contributor

@dafeda dafeda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Blunde1 Blunde1 enabled auto-merge (rebase) January 13, 2022 09:08
@Blunde1 Blunde1 merged commit 19ba42c into equinor:main Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add more documentation about the behavior of the analysis module
3 participants