1#ifndef __JASTRONOMY__JASTRONOMYTOOLKIT__
2#define __JASTRONOMY__JASTRONOMYTOOLKIT__
37 public std::map<int, std::vector<T> >
62 return std::accumulate(this->begin(), this->end(), 0, [](
const size_t n,
const value_type& i) {
return n + i.second.size(); });
74 if (!i->second.empty()) {
75 return *std::min_element(i->second.begin(), i->second.end());
91 if (!i->second.empty()) {
92 return *std::max_element(i->second.begin(), i->second.end());
108 return floor(value *
factor);
119 (*this)[
getKey(value)].push_back(value);
133 if (P < 0.0 || P > 1.0) {
137 const size_t N = this->
getN();
138 const size_t M = N - (size_t) (P * N);
144 if (M == N) {
return this->
getMax(); }
145 if (M == 0) {
return this->
getMin(); }
151 n -= p->second.size();
155 vector<T> buffer(p->second.begin(), p->second.end());
157 sort(buffer.begin(), buffer.end());
159 return buffer[M - n];
175 const int M =
getKey(value);
180 for ( ; i != this->rend() && i->first > M; ++i) {
181 n += i->second.size();
184 if (i != this->rend()) {
185 for (T x : i->second) {
192 return (
double) n / (double) this->
getN();
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for an empty collection.
Exception for accessing a value in a collection that is outside of its range.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary container for statistical analysis of a large number of values.
double getProbability(const double value) const
Get maximal probability corresponding given minimal value.
void put(const T value)
Add value to container.
map_type::value_type value_type
T getMax() const
Get maximal value.
T getMin() const
Get minimal value.
const T factor
scaling factor for rounding value
std::map< int, std::vector< T > > map_type
JQuantile(const double factor)
Constructor.
T getValue(const double P) const
Get minimal value corresponding given maximal probability.
int getKey(const T value) const
Get key of given value.
map_type::const_reverse_iterator const_reverse_iterator
map_type::const_iterator const_iterator
size_t getN() const
Get total number of values.