MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / stdev

Function stdev

libCacheSim/traceAnalyzer/utils/include/utilsMath.h:58–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57template<typename T>
58static inline T stdev(const std::vector<T> &v, size_t ignore_n_first, size_t ignore_n_last) {
59 if (v.size() <= 1) {
60 return (T) 0.0;
61 }
62 if (v.size() <= ignore_n_first + ignore_n_last) {
63 return 0;
64 }
65
66 T mean_ = mean(v, ignore_n_first, ignore_n_last);
67 T sum = (T) 0.0;
68 for (auto it = v.begin() + ignore_n_first; it != v.end() - ignore_n_last; it++) {
69 sum += (*it - mean_) * (*it - mean_);
70 }
71 return (T) sqrt(sum / (v.size() - ignore_n_first - ignore_n_last));
72}
73
74}// namespace mathUtils

Calls 4

meanFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected