marUtils.cpp

Go to the documentation of this file.
00001 
00002 #include "marUtils.h"
00003 
00004 // ----------------------------------------------------------------------------
00005 marUtils::marUtils()
00006 {
00007 
00008 }
00009 
00010 // ----------------------------------------------------------------------------
00011 marUtils::~marUtils()
00012 {
00013 
00014 }
00015 // ----------------------------------------------------------------------------
00016 double marUtils::obtainAverage(std::vector<double> list)
00017 {
00018         double average = 0;
00019         for (int i = 0; i < list.size(); i++)
00020         {
00021                 average += list[i];
00022         }
00023 
00024         if (list.size() > 0)
00025         {
00026                 average = average / list.size();
00027         }
00028 
00029         return average;
00030 
00031 }
00032 
00033 // ----------------------------------------------------------------------------
00034 double marUtils::obtainStandardDeviation(std::vector<double> list, double average)
00035 {
00036         double std = 0;
00037 
00038         for(int i = 0; i < list.size(); i++)
00039         {
00040                 std += pow(list[i] - average,2.0);
00041         }
00042 
00043         if (list.size() > 0)
00044         {
00045                 std = sqrt(std/list.size());
00046         }
00047 
00048         return std;
00049 }

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1