JayBeams  0.1
Another project to have fun coding.
histogram_binning_linear_interpolation.hpp
Go to the documentation of this file.
1 #ifndef jb_histogram_binning_liner_interpolation_hpp
2 #define jb_histogram_binning_liner_interpolation_hpp
3 
4 #include <cmath>
5 
6 namespace jb {
7 
8 /**
9  * Convenience function to implement the @ref binning_strategy_concept.
10  *
11  * The histogram class requires the binning strategy to solve the
12  * follow equation for @f$x@f$:
13  *
14  * @f[
15  * {{(x - x_a)} \over {(y - y_a)}} = {{(x_b - x_a)} \over {s}}
16  * @f]
17  *
18  * this is used in the computation of percentiles to better
19  * approximate the percentile value between different cuts. Some
20  * binning strategies might provide a non-linear interpolation, but in
21  * practice this (linear) solution is used in most cases.
22  */
23 template <typename sample_type>
25  sample_type x_a, sample_type x_b, double y_a, double s, double q) {
26  return sample_type(std::floor(x_a + (q - y_a) * (x_b - x_a) / s));
27 }
28 
29 } // namespace jb
30 
31 #endif // jb_histogram_binning_linear_interpolation_hpp
sample_type histogram_binning_linear_interpolation(sample_type x_a, sample_type x_b, double y_a, double s, double q)
Convenience function to implement the binning_strategy_concept.
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7