OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
common_statistics.hpp
1/*
2 * common_statistics.hpp
3 *
4 * Created on: Jul 20, 2019
5 * Author: i-bird
6 */
7
8#ifndef COMMON_STATISTICS_HPP_
9#define COMMON_STATISTICS_HPP_
10
11
20static inline void standard_deviation(openfpm::vector<double> measures, double & mean, double & dev)
21{
22 mean = 0;
23 for (size_t i = 0 ; i < measures.size() ; i++)
24 mean += measures.get(i);
25 mean /= measures.size();
26
27 dev = 0;
28 for (size_t i = 0 ; i < measures.size() ; i++)
29 dev += (measures.get(i) - mean)*(measures.get(i) - mean);
30
31 dev = sqrt(dev / (measures.size() - 1));
32}
33
42static inline void standard_deviation(std::vector<double> measures, double & mean, double & dev)
43{
44 mean = 0;
45 for (size_t i = 0 ; i < measures.size() ; i++)
46 {
47 mean += measures[i];
48 }
49
50 mean /= measures.size();
51
52 dev = 0;
53 for (size_t i = 0 ; i < measures.size() ; i++)
54 dev += (measures[i] - mean)*(measures[i] - mean);
55
56 dev = sqrt(dev / (measures.size() - 1));
57}
58
59
60#endif /* COMMON_STATISTICS_HPP_ */
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.