1#ifndef __JASTRONOMY__JGARAGE__
2#define __JASTRONOMY__JGARAGE__
27 template<
class T, const
size_t factor = 0>
46 return accumulate(this->begin(), this->end(), 0, [](
const size_t n,
const value_type& buffer) {
return n + buffer.size(); });
61 return *min_element(i->begin(), i->end());
65 throw length_error(
"No data.");
80 return *max_element(i->begin(), i->end());
84 throw length_error(
"No data.");
97 return value * factor;
110 const size_t index =
getKey(value);
112 if (index >= this->size()) {
113 this->resize(index + 1);
116 (*this)[index].push_back(value);
126 template<
class JFunction_t>
127 void put(
const size_t N,
const JFunction_t&
object)
129 for (
size_t i = 0; i != N; ++i) {
140 template<
class JFunction_t>
144 for (
const T x : *i) {
161 if (P < 0.0 || P > 1.0) {
162 throw out_of_range(
"Invalid probability.");
165 const size_t N = this->
getN();
166 const size_t M = N - (P * N);
169 throw length_error(
"No data.");
172 if (M == 0) {
return getMin(); }
173 if (M == N) {
return getMax(); }
179 while ((n -= q->size()) > M) {
185 typename value_type::iterator p = next(buffer.begin(), M - n);
187 nth_element(buffer.begin(), p, buffer.end());
203 const size_t N = this->
getN();
204 const int M =
getKey(value);
207 throw length_error(
"No data.");
211 int i = this->size() - 1;
213 for ( ; i != -1 && i > M; --i) {
214 n += (*this)[i].size();
218 for (
const T x : (*this)[i]) {
225 return (
double) n / (double) N;
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary container for statistical analysis of a large number of positive (or zero) values.
map_type::const_reverse_iterator const_reverse_iterator
map_type::const_iterator const_iterator
void put(const size_t N, const JFunction_t &object)
Add values to container.
T getMax() const
Get maximal value.
static size_t getKey(const T value)
Get hash key corresponding to given value.
double getProbability(const T value) const
Get maximal probability corresponding given minimal value.
T getValue(const double P) const
Get minimal value corresponding given maximal probability.
std::vector< std::vector< T > > map_type
map_type::value_type value_type
size_t getN() const
Get total number of values.
void operator()(const JFunction_t &object) const
For-each method.
T getMin() const
Get minimal value.
void put(const T value)
Add value to container.