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

Generic Bayes bounds computation #175

Open
JelleAalbers opened this issue Sep 27, 2021 · 0 comments
Open

Generic Bayes bounds computation #175

JelleAalbers opened this issue Sep 27, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@JelleAalbers
Copy link
Member

To compute a Bayes bound (#174 / Robert's slides) , we do the same computation as in _compute, but with a size-1 out-axis (e.g. quanta produced) and an enormous in-axis (e.g. quanta detected). That yields an (unnormalized) posterior on the in-variable, from which we extract quantiles to get the desired bounds. A figure might help explain it better:

bounds_illustration

We calculate P(out|in) along the blue and red bands in the figure below, located at the bounds on the out-variable calculated in earlier steps. (For the outer blocks, there is only one band since the out variable is observed.) That gives us two posterior curves, from which we calculate quantiles, e.g. -3 sigma for blue and +3 sigma for red. These set the bounds for the actual block flamedisx uses, drawn as a solid black box.

At the moment, the implementation in #174 essentially re-implements _compute in a numpy-compatible way. That works but is not very maintainable / generalizable. Instead, we could leverage _compute itself to get a simpler Bayes bound routine that works for all blocks, at least 1d and 2d. Something like:

  • In BlockSource.annotate, set _min and _max in the dataframe to the huge proto-bounds (by calling some '_pre_annotate' method on each block perhaps), stepsize to 1, then call Source._populate_tensor_cache to initialize self.data_tensor.
  • In Block.annotate, call Source.ptensor_from_kwargs to get ptensor, and Source.domain for both self.dimensions to get 1d tensors representing the band coordinates. Reshape / add a size-one axis to make those 2d arrays. Then call compute, result.numpy(), find quantiles, set new _min and _max in the dataframe.

(Finally, Source._set_data proceeds as usual with _calculate_dimsizes and _populate_tensor_cache as usual, which updates self.data_tensor to one with correct _min, _max, and stepsize)

@robertsjames robertsjames self-assigned this Sep 28, 2021
@JelleAalbers JelleAalbers added the enhancement New feature or request label Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants