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

◆ zscore()

MAYAFLUX_API double MayaFlux::Kinesis::Discrete::zscore ( std::span< const double >  window,
std::span< const double >  coefs 
)
noexcept

How far the newest value sits from the rest of the window, in standard deviations.

A novelty measure. Not Discrete::mean_zscore, which averages the z-scores of a window about its own mean.

window[0] against the mean and sample standard deviation of window[1..]. coefs[0], when present, is the smallest deviation used as a divisor (default 1e-12), so a flat history does not divide by zero. Fewer than two older values give zero.

Definition at line 438 of file Kernels.cpp.

439{
440 if (window.size() < 3)
441 return 0.0;
442
443 const auto past = window.subspan(1);
444 const double mean = sum_of(past) / static_cast<double>(past.size());
445
446 const double floor = coefs.empty() ? 1e-12 : std::max(coefs.front(), 1e-12);
447 const double deviation = std::max(Stochastic::Estimate::stddev(past), floor);
448 return (window.front() - mean) / deviation;
449}
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
std::vector< double > mean(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Arithmetic mean per window.
Definition Analysis.cpp:200

References mean(), MayaFlux::Kinesis::Stochastic::Estimate::stddev(), and window.

+ Here is the call graph for this function: