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

◆ coherence()

double MayaFlux::Kinesis::coherence ( std::span< const std::span< const double > >  streams)
inlinenoexcept

How tightly a set of streams move together.

Parameters
streamsEach span the same length, at least two spans
Returns
Mean pairwise correlation across all distinct pairs, in -1..1, or zero if fewer than two streams are given

Generalizes correlation from two streams to an arbitrary-size set, with no assumption about which stream is which or how many there are: two tracked hands, five gamepad axes, a whole ensemble's worth of per-voice measurements. A high value means the set is moving as one; a value near zero means the set's motion is not coordinated; a strongly negative value means the set is systematically split into streams moving in opposition to each other.

Mean pairwise rather than a single eigenvalue-based coherence measure: cheap, order-independent, and interpretable directly as a correlation without a caller needing to reason about a covariance matrix's spectrum. A caller wanting the finer-grained structure (which streams are actually forming a bloc) computes correlation() over the specific pairs of interest instead.

Definition at line 227 of file Relation.hpp.

229{
230 const size_t n = streams.size();
231 if (n < 2)
232 return 0.0;
233
234 double acc = 0.0;
235 size_t pairs = 0;
236 for (size_t i = 0; i < n; ++i) {
237 for (size_t j = i + 1; j < n; ++j) {
238 acc += correlation(streams[i], streams[j]);
239 ++pairs;
240 }
241 }
242
243 return (pairs > 0) ? (acc / static_cast<double>(pairs)) : 0.0;
244}
double correlation(std::span< const double > a, std::span< const double > b) noexcept
Pearson correlation between two equal-length windows.
Definition Relation.hpp:45

References correlation().

+ Here is the call graph for this function: