triqs::stat::mean

#include <triqs/stat.hpp>

Synopsis

template<typename V>
auto mean (V const & data)

Calculate the arithmetic mean [REF] of data in an iterable container.

Template parameters

  • V iterable type. Pre-conditions: elements must be addable to each other

Parameters

  • data Container with data

Returns

Mean of data; type is deduced from first element of data

Example

#include <triqs/stat/mean_error.hpp>

using namespace triqs::stat;

int main() {
  std::vector<double> data{1., 2., 3., 4.};
  auto ave = mean(data);
  std::cout << "Average: " << ave << std::endl; // = 2.5
}

Output

Average: 2.5