29 std::enable_if_t<std::is_invocable_v<Transform, uint32_t>> * =
nullptr>
32 cumulative_.resize(
data.size() + 1);
34 for (
const auto &[i, value] : utils::enumerate(
data))
35 cumulative_[i + 1] = cumulative_[i] + transform(value);
38 size_t bins()
const {
return cumulative_.size() - 1; }
39 std::span<const uint64_t>
data()
const {
return cumulative_; }
40 uint64_t
total()
const {
return cumulative_.back(); }
42 double quantile(
double q, uint32_t first = 0, uint32_t last = UINT_MAX)
const;
47 return cumulative_[bin + 1] - cumulative_[bin];
51 std::vector<uint64_t> cumulative_;
The base class for creating histograms.
Definition histogram.h:23
Histogram()
Construct an empty Histogram.
Definition histogram.h:25
double quantile(double q, uint32_t first=0, uint32_t last=UINT_MAX) const
Return the (fractional) bin of the point through the histogram.
Definition histogram.cpp:117
uint32_t operator[](size_t bin) const
Retrieve the value for bin.
Definition histogram.h:45
uint64_t total() const
Retrieve the total number of values in the data set.
Definition histogram.h:40
uint64_t cumulativeFrequency(double bin) const
Cumulative frequency up to a (fractional) point in a bin.
Definition histogram.cpp:94
size_t bins() const
Retrieve the number of bins currently used by the Histogram.
Definition histogram.h:38
Histogram(std::span< const uint32_t > data, Transform transform)
Create a cumulative histogram.
Definition histogram.h:30
std::span< const uint64_t > data() const
Retrieve the internal data.
Definition histogram.h:39
double interQuantileMean(double lowQuantile, double hiQuantile) const
Calculate the mean between two quantiles.
Definition histogram.cpp:155
Top-level libcamera namespace.
Definition backtrace.h:17
Transform
Enum to represent a 2D plane transform.
Definition transform.h:14
Miscellaneous utility functions.