Skip to content

Generic Bayes bounds computation #175

@JelleAalbers

Description

@JelleAalbers

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)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions