Skip to content

Functions for calculating the DA estimator - #62

Open
louisekluge wants to merge 22 commits into
mainfrom
da_estimator
Open

Functions for calculating the DA estimator#62
louisekluge wants to merge 22 commits into
mainfrom
da_estimator

Conversation

@louisekluge

Copy link
Copy Markdown
Collaborator

Facilities for calculating the the MLDA estimator in the two-level case, as well as associated variances

@louisekluge
louisekluge marked this pull request as draft October 8, 2024 11:16
@louisekluge
louisekluge requested a review from mikkelbue October 9, 2024 12:01
@louisekluge

Copy link
Copy Markdown
Collaborator Author

Hi, I am still trying to figure out many things and a few questions with regard to design have come up:

  1. Do you generally think that the two functions as I sketched them are suitable?
  2. If I want to do the get_DA_samples function in analogy to get_samples, I need to modify sampler.py first, so that it the dict that is returned by tda.sample contains also promoted_coarse? Is that something we want generally in the two level/multilevel case?

@mikkelbue

Copy link
Copy Markdown
Owner

@louisekluge

  1. I think the best way to do this would be to allow compiling an InferenceData object for the promoted_coarse samples. That way we could easily compute the difference for any quantity, parameters, or qoi or whatever. I would adapt the get_samples function to accept level="promoted_coarse" as an input to condstruct that InferenceData object. Then we can use a function like the one you have sketched DA_estimator(inferencedata_fine, inferencedata_coarse_promoted, attribute) to compute the estimator.
  2. Yes you would have to modify sampler.py to return the additional list. I have made some changes to the RemoteChain class that handles the parallelisation which should make this a lot easier for the parallel case. They are on this branch https://github.com/mikkelbue/tinyDA/tree/mikkel-ray_refactor .. Could you test that branch for me? Then I will merge it.

@louisekluge
louisekluge marked this pull request as ready for review December 12, 2024 13:15
@louisekluge

Copy link
Copy Markdown
Collaborator Author

Hi, I think this is ok now. I did some tests with the Multilevel Delayed Acceptance notebook setup and it works fine I think.

@mikkelbue mikkelbue left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good. I have a couple of stylistic suggestions. Please can you also run black on the code?

Comment thread tinyDA/diagnostics.py Outdated
Comment thread tinyDA/diagnostics.py Outdated
Comment thread tinyDA/diagnostics.py Outdated
louisekluge and others added 4 commits January 10, 2025 14:58
@louisekluge
louisekluge requested a review from mikkelbue February 6, 2025 15:07
@louisekluge

Copy link
Copy Markdown
Collaborator Author

I had a thought about burnin: when I subtract the burnin in calculating the multilevel estimator, the burnin subtracted on the coarse level should be burnin*subchain_length, as burnin generally refers to the fine chain. I will adapt this accordingly.

@mikkelbue mikkelbue left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good. Please add some comments that explains what the code does throughout. Thanks!

Comment thread tinyDA/diagnostics.py Outdated
Comment thread tinyDA/diagnostics.py Outdated
Comment thread tinyDA/diagnostics.py Outdated
Comment on lines +263 to +266
mean_difference = az.summary(values_difference, var_names=[variable]).loc[
variable, "mean"
]
mean_coarse = az.summary(values_coarse, var_names=[variable]).loc[variable, "mean"]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why not just compute the mean directly rather than the entire summary and then extract the mean. There should be a faster way of doing this.

Co-authored-by: Mikkel Bue <mikkelbue@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants