34 : m_x_sampling(
std::move(other.m_x_sampling)), m_y_sampling(
std::move(other.m_y_sampling)) {}
51 : m_x_sampling(x_sampling), m_y_sampling(y_sampling) {
52 if (x_sampling.
size() != y_sampling.
size()) {
58 auto iter = sampling.begin();
59 while (iter != sampling.end()) {
60 m_x_sampling.push_back((*iter).first);
61 m_y_sampling.push_back((*iter).second);
69 auto iter = sampling.
begin();
70 while (iter != sampling.
end()) {
71 xs.push_back((*iter).first);
72 ys.push_back((*iter).second);
81 auto iter_pdf = pdf_sampling.
cbegin();
83 while (iter_pdf != pdf_sampling.
cend()) {
85 cumul.push_back(total);
97 cumul.push_back(*iter / total);
105 if (ratio > 1. || ratio < 0.) {
106 throw Elements::Exception(
"Cumulative::findValue : ratio parameter must be in range [0,1]");
115 double begin_value = *iter_x;
116 double tray = *iter_y;
122 double end_value = *(--iter_x);
126 case TrayPosition::begin:
127 result = begin_value;
129 case TrayPosition::middle:
130 result = 0.5 * (begin_value + end_value);
132 case TrayPosition::end:
142 if (rate > 1. || rate <= 0.) {
143 throw Elements::Exception(
"Cumulative::findMinInterval : rate parameter must be in range ]0,1]");
157 while (iter_2_x !=
m_x_sampling.
cend() && (*iter_2_y - *iter_1_y + first_correction) < rate) {
164 if ((*iter_2_x - *iter_1_x) <= (*max_x - *min_x)) {
170 first_correction = 0.;
177 if (rate > 1. || rate <= 0.) {
178 throw Elements::Exception(
"Cumulative::findCenteredInterval : rate parameter must be in range ]0,1]");
181 double min_rate = 0.5 - rate / 2.0;
182 double max_rate = 0.5 + rate / 2.0;
184 double min_x =
findValue(min_rate, TrayPosition::end);
185 double max_x =
findValue(max_rate, TrayPosition::begin);