 |
AGXDynamics
2.35.0.2
|
Go to the documentation of this file.
66 : m_statistic(statistic)
73 return std::move(m_statistic);
81 std::unique_ptr<Statistic> m_statistic;
101 : m_smoothFactor( smoothFactor ), m_s( initialObservation ) {}
105 m_s += m_smoothFactor * ( observation - m_s );
159 agx::Real absDeltaObservation = std::abs( m_s - observation );
160 agx::Real absStatistic = std::abs( m_s );
161 agx::Real alpha = ( absDeltaObservation > 0 && absStatistic > 0 ? absStatistic / absDeltaObservation : m_smoothFactor );
163 m_s += alpha * ( observation - m_s );
187 : m_maxHistorySize(maxHistorySize)
189 m_historyByAge.reserve(m_maxHistorySize);
190 m_historyByValue.reserve(m_maxHistorySize);
198 size_t n = this->getCurrentHistorySize();
205 size_t middle = n / 2;
208 return (m_historyByValue[middle - 1] + m_historyByValue[middle]) /
agx::Real(2.0);
211 return m_historyByValue[middle];
222 while (this->getCurrentHistorySize() >= this->getMaxHistorySize()) {
224 m_historyByAge.pop_back();
225 m_historyByValue.findAndErase(v,
false);
230 auto insertAt = lower_bound(
begin(m_historyByValue),
end(m_historyByValue), observation);
231 m_historyByValue.insert(insertAt, observation);
232 m_historyByAge.insert(
size_t(0), observation);
240 m_historyByAge.clear();
241 m_historyByValue.clear();
247 return m_maxHistorySize;
254 agxAssert(m_historyByAge.size() == m_historyByValue.size());
255 size_t n = m_historyByAge.size();
262 return m_historyByAge;
268 return m_historyByValue;
277 size_t m_maxHistorySize;
virtual ~VariableSmoothFactorEMAStatistic()
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
static StatisticHandleRef make_statistic(agx::Real maxSmoothingFactor, agx::Real initialObservation=0)
static StatisticHandleRef make_statistic(agx::Real maxSmoothingFactor, agx::Real initialObservation=0)
StatisticHandle(Statistic *statistic)
agx::Real getSmoothFactor() const
void setSmoothFactor(agx::Real smoothFactor)
#define AGXPHYSICS_EXPORT
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
virtual agx::Real update(agx::Real observation)
Updates the statistic given the current observation and returns the current value of this statistic.
Pure virtual statistic class containing the fundamentals for implementing a statistics method.
T1 clamp(T1 v, T2 minimum, T3 maximum)
Smart pointer for handling referenced counted objects.
virtual ~StatisticHandle()
virtual agx::Real update(agx::Real observation)
Updates the statistic given the current observation and returns the current value of this statistic.
VariableSmoothFactorEMAStatistic(agx::Real maxSmoothingFactor, agx::Real initialObservation=0)
ExponentialMovingAverageStatistic(agx::Real smoothFactor, agx::Real initialObservation=0)
Base class providing referencing counted objects.
#define AGX_DECLARE_POINTER_TYPES(type)
virtual ~ExponentialMovingAverageStatistic()
Extra level of indirection provided for use by garbage collected languages.
std::unique_ptr< Statistic > takeStatistic()
Exponential moving average statistic.
virtual agx::Real get() const
void set(agx::Real val)
Set the raw value of the statistic scalar.
Variable Smooth Factor Exponential Moving Average statistic.
The agxUtil namespace contain classes and methods for utility functionality.