mcpele
1.0.0
The Monte Carlo Python Energy Landscape Explorer
|
00001 #ifndef _MCPELE_RECORD_SCALAR_TIMESERIES_H__ 00002 #define _MCPELE_RECORD_SCALAR_TIMESERIES_H__ 00003 00004 #include "mc.h" 00005 00006 namespace mcpele { 00007 00011 class RecordScalarTimeseries : public Action{ 00012 private: 00013 const size_t m_record_every; 00014 std::vector<double> m_time_series; 00015 void m_record_scalar_value(const double input) 00016 { 00017 m_time_series.push_back(input); 00018 } 00019 public: 00020 RecordScalarTimeseries(const size_t, const size_t); 00021 virtual ~RecordScalarTimeseries(){} 00022 virtual void action(pele::Array<double> &coords, double energy, bool accepted, MC* mc); 00023 virtual double get_recorded_scalar(pele::Array<double> &coords, const double energy, const bool accepted, MC* mc) = 0; 00024 bool moving_average_is_stable(const size_t nr_steps_to_check=1000, const double rel_std_threshold=0.1); 00025 std::pair<double, double> get_moving_average_mean(const size_t nr_steps_to_check); //returns first moment of ma 00026 std::pair<double, double> get_moving_average_variance(const size_t nr_steps_to_check); //returns second central moments of ma 00027 pele::Array<double> get_time_series() 00028 { 00029 m_time_series.shrink_to_fit(); 00030 return pele::Array<double>(m_time_series).copy(); 00031 } 00032 void clear() 00033 { 00034 m_time_series.clear(); 00035 } 00036 }; 00037 00038 } // namespace mcpele 00039 00040 #endif // #ifndef _MCPELE_RECORD_SCALAR_TIMESERIES_H__