boostorg / histogram

Fast multi-dimensional generalized histogram with convenient interface for C++14
Boost Software License 1.0
313 stars 74 forks source link

Best way to change the bounds of the histogram #333

Closed vakokako closed 2 years ago

vakokako commented 2 years ago

I want to update the histogram to new bounds, same as algorithm::shrink, but for both shrinking and growing.

Something like shrinkOrExpand:

auto hist = make_histogram_with(std::vector<size_t>(), axis::regular(5, 0, 10));

// new histogram with bounds [4, 14):
auto hist2 = algorithm::reduce(hist, algorithm::shrinkOrExpand(4, 13));

What is the best way to do this?

HDembinski commented 2 years ago

Expanding is intentionally not supported. There is a unique and unambiguous way to shrink a histogram that was already filled, but you cannot expand it unambiguously after it was already filled.

vakokako commented 2 years ago

The issue comes with under/overflow bins, correct? In our current use case, we wrap our own 1d histogram around boost::histogram and we would still like to extend our class with this functionality for 1d case, throwing if the under/overflow bins are present. Could you point to some methods (maybe in namespace detail) that would help us do it?