34   template<
int N = 1, 
class RealType = 
double>
 
   36     static_assert(N > 0, 
"Number of parameters, N, must be positive");
 
   48       for (
int i = 0; i < N; i++)
 
   50       for (
int i = 0; i < N * (N + 1) / 2; i++)
 
   61       static_assert(
sizeof...(values) == N,
 
   62                     "Number of arguments must be equal N");
 
   64       addValue<0>(weight, values...);
 
   71     template<
class... T> 
void add(T... values)
 
   82       for (
int i = 0; i < N; ++i) {
 
   85         for (
int j = i; j < N; ++j) {
 
  132       if (i == j) 
return 1.0;
 
  154       static_assert(i >= 0 && i < N, 
"index i out of range");
 
  160       static_assert(i >= 0 && i < N, 
"index i out of range");
 
  161       static_assert(j >= 0 && j < N, 
"index j out of range");
 
  168       if (i == j) 
return 1.0;
 
  170       return getCovariance<i, j>() / (getStddev<i>() * getStddev<j>());
 
  175       return getCovariance<i, i>();
 
  180       return std::sqrt(getVariance<i>());
 
  198     template<
int i, 
class... T>
 
  203       updateCov<i, i>(weight, delta, x, values...);
 
  207       addValue < i + 1 > (weight, values...);
 
  221     template<
int i, 
int j, 
class... T>
 
  228       updateCov < i, j + 1 > (weight, delta, values...);
 
  242       for (
int i = 0; i < N; ++i) {
 
  245         for (
int j = i; j < N; ++j) {
 
  260     constexpr 
int getIndex(
unsigned int i, 
unsigned int j)
 const 
  263       return (i < j) ? ((j + 1) * j / 2 + i) : ((i + 1) * i / 2 + j);
 
Class to calculate mean and and covariance between a number of parameters on running data without sto...
value_type m_entries
Store the sum of weights.
void addWeighted(value_type weight, T... values)
Update mean and covariance by adding a new, weighted entry.
value_type getVariance(int i) const
Return the variance for paramter i.
void add(const CalcMeanCov< N, RealType > &other)
Merge the data set in 'other' into this one.
void addValue(value_type)
Break recursion of addValue when no parameters are left.
void updateCov(value_type weight, value_type delta, value_type x, T... values)
Update covariance between parameters i and j.
value_type getCorrelation(int i, int j) const
Return the correlation coefficient between parameters i and j.
value_type getStddev() const
Return the standard deviation for parameter i.
value_type getStddev(int i) const
Return the standard deviation for parameter i.
value_type getMean(int i) const
Return the mean for parameter i.
value_type getMean() const
Return the mean for parameter i.
constexpr int getIndex(unsigned int i, unsigned int j) const
Access element in triangular matrix including diagonal elements.
RealType value_type
type of float variable to use for calculations and storage
value_type getVariance() const
Return the variance for paramter i.
value_type m_mean[N]
Store the mean values for all parameters.
value_type getSum() const
Return the weighted sum values for parameter i.
value_type getCovariance(int i, int j) const
Return the covariance between parameters i and j.
value_type getCovariance() const
Return the covariance between parameters i and j.
value_type m_covariance[N *(N+1)/2]
Store the triangular covariance matrix for all parameters in continous memory.
void addArrayValues(value_type weight, value_type *x)
Add a new set of values and update mean and covariance.
void addArray(value_type *values)
Update mean and covariance by adding a new entry.
value_type getCorrelation() const
Return the correlation coefficient between parameters i and j.
void addWeightedArray(value_type weight, value_type *values)
Update mean and covarianced by adding a new weighted entry.
void updateCov(value_type, value_type)
Break recursion of updateCov once all parameters are consumed.
value_type getSum(int i) const
Return the weighted sum values for parameter i.
CalcMeanCov()
default constructor.
void add(T... values)
Update mean and covariance by adding a new entry.
void clear()
Clear all values.
void addValue(value_type weight, value_type x, T... values)
Add a single value for parameter i and update mean and covariance.
value_type getEntries() const
Return the number of entries.
Abstract base class for different kinds of events.