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

Add collector accumulator #349

Open
HDembinski opened this issue Jan 19, 2022 · 1 comment
Open

Add collector accumulator #349

HDembinski opened this issue Jan 19, 2022 · 1 comment

Comments

@HDembinski
Copy link
Collaborator

HDembinski commented Jan 19, 2022

A simple accumulator that just fills a std::vector with the samples passed to it. The user can then run any kind of statistical estimation on the sample. It is a very inefficient accumulator, but sometimes that's acceptable and the flexibility it offers is more important than the performance.

Pseudo-code

// C++17
namespace bh = boost::histogram;
auto h = bh::make_histogram(bh::axis::integer(0, 2),
              bh::dense_storage<bh::accumulators::Collector<>>());

// fill
h(0, 1);
h(0, 2);
h(0, 3);
h(1, 4);
h(1, 5);

for (auto x: h.at(0))
   std::cout << x << std::endl;

Prints: 1 2 3

@wiso
Copy link
Contributor

wiso commented Nov 6, 2023

I think this would be a very nice feature since this is basically a groupby. I have submitted a simple PR. I am using collector instead of Collector for consistency with the other accumulators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants