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

◆ interval_share_above()

MAYAFLUX_API std::vector< double > MayaFlux::Kinesis::Discrete::interval_share_above ( std::span< const double > values,
std::span< const size_t > positions,
const std::vector< std::pair< size_t, size_t > > & intervals,
double threshold )
nodiscard

Share of the values inside each interval that are at or above a threshold.

Parameters
valuesOne value per position
positionsSample position of each value, ascending
intervals[start, end) pairs; a value belongs to an interval holding its position
thresholdValue at or above which a value counts
Returns
One share in [0, 1] per interval, 0 for an interval holding no values

Definition at line 94 of file Extract.cpp.

99{
100 std::vector<double> out;
101 out.reserve(intervals.size());
102 for (const auto& interval : intervals) {
103 const auto inside = values_inside(values, positions, interval);
104 const auto above = std::ranges::count_if(inside, [threshold](double v) { return v >= threshold; });
105 out.push_back(inside.empty() ? 0.0 : static_cast<double>(above) / static_cast<double>(inside.size()));
106 }
107 return out;
108}
Tendency< D, float > threshold(const Tendency< D, float > &t, float thresh)
Zero output below threshold, pass through above.
Definition Tendency.hpp:142

References MayaFlux::Kinesis::threshold().

Referenced by MayaFlux::Yantra::measure_voicing().

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