MCPcopy Create free account
hub / github.com/alandefreitas/matplotplusplus / histogram_count

Method histogram_count

source/matplot/axes_objects/histogram.cpp:527–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525 }
526
527 std::vector<size_t>
528 histogram::histogram_count(const std::vector<double> &data,
529 const std::vector<double> &edges) {
530 std::vector<size_t> bin_counts(edges.size() - 1, 0);
531 for (const double &v : data) {
532 // find first edge that does not compare less than v
533 auto it = std::lower_bound(edges.begin(), edges.end(), v);
534 bool out_of_range = it == edges.begin() || it == edges.end();
535 if (!out_of_range) {
536 ++bin_counts[it - edges.begin() - 1];
537 } else if (it == edges.begin()) {
538 if (v == *it) {
539 ++bin_counts[0];
540 }
541 }
542 }
543 return bin_counts;
544 }
545
546 std::vector<double>
547 histogram::histogram_normalize(const std::vector<size_t> &bin_count,

Callers

nothing calls this directly

Calls 3

beginMethod · 0.80
endMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected