RMOL Logo Get Revenue Management Optimisation Library at SourceForge.net. Fast, secure and Free Open Source software downloads

HistoricalDataHolder.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // GSL Random Number Generation 
00005 // (GSL Reference Manual, version 1.7, Chapter 19)
00006 #include <gsl/gsl_cdf.h>
00007 #include <gsl/gsl_randist.h>
00008 // C
00009 #include <assert.h>
00010 #include <math.h>
00011 // STL
00012 #include <iostream>
00013 //#include <iomanip>
00014 //#include <cmath>
00015 // RMU
00016 #include <rmol/bom/HistoricalDataHolder.hpp>
00017 
00018 namespace RMOL {
00019 
00020   // //////////////////////////////////////////////////////////////////
00021   HistoricalDataHolder::HistoricalDataHolder () {
00022   }
00023 
00024   // //////////////////////////////////////////////////////////////////
00025   HistoricalDataHolder::~HistoricalDataHolder () {
00026     _historicalDataVector.clear();
00027   }
00028 
00029   // //////////////////////////////////////////////////////////////////
00030   const double HistoricalDataHolder::getMean () const {
00031     double lResult = 0.0;
00032     const double& lSize = getNumberOfHistoricalData();
00033 
00034     for (short ite = 0; ite < lSize; ++ite) {
00035       const double& lHistoricalData = getHistoricalData(ite);
00036       lResult += (lHistoricalData);
00037     }
00038 
00039     lResult /= lSize;
00040 
00041     return lResult;
00042   }
00043 
00044   // //////////////////////////////////////////////////////////////////
00045   const double HistoricalDataHolder::getStandardDeviation
00046   (const double& iMean) const {
00047     double lResult = 0.0;
00048     const double& lSize = getNumberOfHistoricalData();
00049 
00050     for (short ite = 0; ite < lSize; ++ite) {
00051       const double& lHistorialData = getNumberOfHistoricalData();
00052       lResult += 
00053          (lHistorialData - iMean) * (lHistorialData - iMean);
00054     }
00055 
00056     lResult /= (lSize - 1);
00057 
00058     lResult = sqrt (lResult);
00059 
00060     return lResult;
00061   }
00062 
00063   // //////////////////////////////////////////////////////////////////
00064   void HistoricalDataHolder::toStream (std::ostream& ioOut) const {
00065     const double& lSize = getNumberOfHistoricalData();
00066 
00067     ioOut << "Historical Data Vector: " << std::endl;
00068 
00069     for (short ite = 0; ite < lSize; ++ite) {
00070       const double& lHistoricalData = getHistoricalData(ite);
00071       ioOut << lHistoricalData << " "
00072             << std::endl;
00073     }
00074   }
00075 
00076   // //////////////////////////////////////////////////////////////////////
00077   const std::string HistoricalDataHolder::describe() const {
00078     std::ostringstream ostr;
00079     ostr << "Holder of historical data.";
00080      
00081     return ostr.str();
00082   }
00083     
00084   // //////////////////////////////////////////////////////////////////
00085   void HistoricalDataHolder::display() const {
00086     toStream (std::cout);
00087   }
00088     
00089 }
SourceForge Logo

Generated on Fri Jul 30 21:53:39 2010 for RMOL by Doxygen 1.6.1