Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
Series.h
Go to the documentation of this file.
1#ifndef SERIES_H
2#define SERIES_H
3
4#include <string>
5#include <vector>
6#include <iostream>
7#include <algorithm>
8#include <cmath>
9#include <memory>
10
40template <typename T>
41class Series {
42private:
43 std::string name;
44 std::vector<T> data;
45 std::shared_ptr<std::vector<std::string>> index;
46public:
52 Series() : index(std::make_shared<std::vector<std::string>>()) {}
53
59 Series(const std::string& colName);
60
69 void add(const T& value);
70
79 void add(const T& value, const std::string& idx) {
80 data.push_back(value);
81 index->push_back(idx);
82 }
83
92 T iat(size_t idx) const;
93
105 T at(const std::string& idx) const;
106
110 size_t size() const;
111
117 const std::string& getName() const;
118
124 void print() const;
125
133 T min() const;
134
142 T max() const;
143
151 double mean() const;
152
163 double stddev() const;
164
175 std::vector<T> quartiles() const;
176
182 const std::shared_ptr<std::vector<std::string>>& getIndex() const {
183 return index;
184 }
185
189 std::vector<T> to_vec() {
190 return data;
191 }
192
199 std::vector<std::string> to_string_vec() {
200 std::vector<std::string> res{};
201 for (auto _ : data) {
202 res.push_back(std::to_string(_));
203 }
204 return res;
205 }
206};
207
208#include "Series.tpp"
209
210#endif // SERIES_H
Generic one-dimensional container of values with optional string index.
Definition Series.h:41
std::vector< T > quartiles() const
Returns the first, second (median), and third quartiles.
T min() const
Returns the minimum value in the series.
Series(const std::string &colName)
Constructs a Series with a given column name.
const std::shared_ptr< std::vector< std::string > > & getIndex() const
Accessor to the shared index vector.
Definition Series.h:182
std::vector< std::string > to_string_vec()
Returns a vector of stringified values.
Definition Series.h:199
T at(const std::string &idx) const
Label-based access to a value.
const std::string & getName() const
Returns the series name.
double mean() const
Computes the arithmetic mean of the series.
T iat(size_t idx) const
Positional access to the i-th element.
void print() const
Prints all stored values to std::cout.
Series()
Default constructor.
Definition Series.h:52
double stddev() const
Computes the (population) standard deviation of the series.
T max() const
Returns the maximum value in the series.
void add(const T &value, const std::string &idx)
Appends a value with an associated index label.
Definition Series.h:79
size_t size() const
Returns the number of elements stored in the series.
void add(const T &value)
Appends a value at the end of the series (without index).
std::vector< T > to_vec()
Returns a copy of the underlying data as a std::vector.
Definition Series.h:189
Hash specialization for SymbolId<Tag>.
Definition BlockName.h:353
double T(double x)
Wilson coefficient T(x).