lib/time_data.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <cmath>
14 #include "../../include/ecl/time/time_data.hpp"
15 
16 /*****************************************************************************
17 ** Namespaces
18 *****************************************************************************/
19 
20 namespace ecl {
21 
22 /*****************************************************************************
23 ** Implementation [TimeData]
24 *****************************************************************************/
25 
27  double sum = 0.0;
28  for ( unsigned int i = 0; i < durations.size(); ++i ) {
29  sum += durations[i];
30  }
31  return ecl::Duration(sum/static_cast<double>(durations.size()));
32 };
33 
35  ecl::Duration avg = average();
36  double sum = 0.0;
37  for ( unsigned int i = 0; i < durations.size(); ++i ) {
38  sum += (static_cast<double>(durations[i]) - static_cast<double>(avg))*
39  (static_cast<double>(durations[i]) - static_cast<double>(avg));
40  }
41  return ecl::Duration(sqrt(sum/static_cast<double>(durations.size())));
42 };
43 
45  ecl::Duration avg = average();
46  double sum = 0.0;
47  for ( unsigned int i = 0; i < durations.size(); ++i ) {
48  sum += (static_cast<double>(durations[i]) - static_cast<double>(avg))*
49  (static_cast<double>(durations[i]) - static_cast<double>(avg));
50  }
51  return ecl::Duration(sum/static_cast<double>(durations.size()));
52 };
53 
54 } // namespace ecl
55 
std::vector< ecl::Duration > durations
Definition: time_data.hpp:75
Embedded control libraries.
ecl::Duration average() const
Return the average of the elements currently stored.
TimeStamp Duration
Convenience typedef to associate timestamps with the concept of durations.
Definition: duration.hpp:41
ecl::Duration stdDev() const
Return the standard deviation of the elements currently stored.
ecl::Duration variance() const
Return the variance of the elements currently stored.


ecl_time
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:15