MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ update_quiet_period()

double MayaFlux::Kinesis::Stochastic::Estimate::update_quiet_period ( double  sample)
private

Definition at line 119 of file Estimate.cpp.

120{
121 m_history.push(sample);
122
124 m_state.filtered_value = sample;
125 return m_state.floor;
126 }
127
128 const auto view = m_history.linearized_view();
129
130 std::vector<double> chronological(view.rbegin(), view.rend());
131 std::span<const double> ordered(chronological);
132
133 const double mean = std::accumulate(chronological.begin(), chronological.end(), 0.0) / static_cast<double>(chronological.size());
134 const double window_stddev = stddev(view);
135 const double trend_ratio = trend_explained_ratio(ordered);
136
137 const bool looks_quiet = trend_ratio < 0.5;
138
139 if (looks_quiet) {
141 m_state.running_variance = window_stddev * window_stddev;
142 m_state.floor = window_stddev;
144 } else {
145 m_state.filtered_value = sample;
146 }
147
148 return m_state.floor;
149}
static double trend_explained_ratio(std::span< const double > samples) noexcept
Fraction of a span's variance attributable to its linear trend.
Definition Estimate.cpp:270
Memory::HistoryBuffer< double > m_history
Definition Estimate.hpp:400
static double stddev(std::span< const double > samples) noexcept
Standard deviation of a span.
Definition Estimate.cpp:224
std::span< T > linearized_view()
Get mutable linearized view of entire history.
void push(const T &value)
Push new value to front of history.
double mean(const std::vector< double > &data)
Calculate mean of single-channel data.
Definition Yantra.cpp:55

References MayaFlux::Kinesis::Stochastic::EstimateState::filtered_value, MayaFlux::Kinesis::Stochastic::EstimateState::floor, MayaFlux::Memory::HistoryBuffer< T >::linearized_view(), m_history, m_state, m_window, MayaFlux::mean(), MayaFlux::Memory::HistoryBuffer< T >::push(), MayaFlux::Kinesis::Stochastic::EstimateState::running_mean, MayaFlux::Kinesis::Stochastic::EstimateState::running_variance, MayaFlux::Kinesis::Stochastic::EstimateState::sample_count, stddev(), and trend_explained_ratio().

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: