time_data.cpp
Go to the documentation of this file.
00001 
00009 /*****************************************************************************
00010 ** Includes
00011 *****************************************************************************/
00012 
00013 #include <cmath>
00014 #include "../../include/ecl/time/time_data.hpp"
00015 
00016 /*****************************************************************************
00017 ** Namespaces
00018 *****************************************************************************/
00019 
00020 namespace ecl {
00021 
00022 /*****************************************************************************
00023 ** Implementation [TimeData]
00024 *****************************************************************************/
00025 
00026 ecl::Duration TimeData::average() const {
00027         double sum = 0.0;
00028         for ( unsigned int i = 0; i < durations.size(); ++i ) {
00029                 sum += durations[i];
00030         }
00031         return ecl::Duration(sum/static_cast<double>(durations.size()));
00032 };
00033 
00034 ecl::Duration TimeData::stdDev() const {
00035         ecl::Duration avg = average();
00036         double sum = 0.0;
00037         for ( unsigned int i = 0; i < durations.size(); ++i ) {
00038                 sum += (static_cast<double>(durations[i]) - static_cast<double>(avg))*
00039                                 (static_cast<double>(durations[i]) - static_cast<double>(avg));
00040         }
00041         return ecl::Duration(sqrt(sum/static_cast<double>(durations.size())));
00042 };
00043 
00044 ecl::Duration TimeData::variance() const {
00045         ecl::Duration avg = average();
00046         double sum = 0.0;
00047         for ( unsigned int i = 0; i < durations.size(); ++i ) {
00048                 sum += (static_cast<double>(durations[i]) - static_cast<double>(avg))*
00049                                 (static_cast<double>(durations[i]) - static_cast<double>(avg));
00050         }
00051         return ecl::Duration(sum/static_cast<double>(durations.size()));
00052 };
00053 
00054 } // namespace ecl
00055 


ecl_time
Author(s): Daniel Stonier
autogenerated on Wed Aug 26 2015 11:27:17