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

◆ variance()

double MayaFlux::Kinesis::Stochastic::Estimate::variance ( std::span< const double >  samples)
staticnoexcept

Sample variance of a span.

Parameters
samplesValues to analyze
Returns
Variance, or 0.0 for spans of size < 2

Definition at line 210 of file Estimate.cpp.

211{
212 if (samples.size() < 2)
213 return 0.0;
214
215 const double mean = std::accumulate(samples.begin(), samples.end(), 0.0) / static_cast<double>(samples.size());
216
217 double sq_sum = 0.0;
218 for (double v : samples)
219 sq_sum += (v - mean) * (v - mean);
220
221 return sq_sum / static_cast<double>(samples.size() - 1);
222}
double mean(const std::vector< double > &data)
Calculate mean of single-channel data.
Definition Yantra.cpp:55

References MayaFlux::mean().

Referenced by update_rolling_variance().

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