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

Function bin_pickerbl

source/matplot/axes_objects/histogram.cpp:347–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345 }
346
347 std::vector<double> bin_pickerbl(double xmin, double xmax, double minlimit,
348 double maxlimit, double bin_width) {
349 double xscale = std::max(std::abs(xmin), std::abs(xmax));
350 double xrange = xmax - xmin;
351 bin_width = std::max(bin_width, nextafter(xscale, xscale + 1 - xscale));
352 bool non_constant_data =
353 xrange > std::max(sqrt(nextafter(xscale, xscale + 1 - xscale)),
354 std::numeric_limits<double>::min());
355 if (non_constant_data) {
356 size_t nbins = std::max(
357 static_cast<size_t>(((maxlimit - minlimit) / bin_width) + 0.5),
358 static_cast<size_t>(1));
359 return linspace(minlimit, maxlimit, nbins + 1);
360 } else {
361 return std::vector<double>({minlimit, maxlimit});
362 }
363 }
364
365 std::vector<double> histogram::scotts_rule(const std::vector<double> &x,
366 double minx, double maxx,

Callers 2

scotts_ruleMethod · 0.85
fd_ruleMethod · 0.85

Calls 3

linspaceFunction · 0.85
maxFunction · 0.50
minFunction · 0.50

Tested by

no test coverage detected