Create comprehensive analysis result.
603 {
605
606 StatisticalAnalysis result;
610
611 if (stat_values.empty()) {
612 return result;
613 }
614
615 result.channel_statistics.resize(stat_values.size());
616
617 for (size_t ch = 0; ch < stat_values.size(); ++ch) {
618 auto& channel_result = result.channel_statistics[ch];
619 const auto& ch_stats = stat_values[ch];
620
621 channel_result.statistical_values = ch_stats;
622
623 if (ch_stats.empty())
624 continue;
625
626 const auto [min_it, max_it] = std::ranges::minmax_element(ch_stats);
627 channel_result.min_stat = *min_it;
628 channel_result.max_stat = *max_it;
629
630 const std::span<const double> sp(ch_stats);
631 const auto sz = static_cast<uint32_t>(ch_stats.size());
632
633 const auto single = [&](auto fn) { return fn(sp, 1, 0, sz)[0]; };
634
635 channel_result.mean_stat = single([](
auto&&...
a) {
return D::mean(
a...); });
637 channel_result.stat_std_dev = std::sqrt(channel_result.stat_variance);
638 channel_result.skewness = single([](
auto&&...
a) {
return D::skewness(
a...); });
639 channel_result.kurtosis = single([](
auto&&...
a) {
return D::kurtosis(
a...); });
640 channel_result.median = single([](
auto&&...
a) {
return D::median(
a...); });
641
642 channel_result.percentiles = {
644 channel_result.median,
646 };
647
648 const size_t data_size = (ch < original_data.size()) ? original_data[ch].
size() : 0;
649 channel_result.window_positions.reserve(ch_stats.size());
650 for (size_t i = 0; i < ch_stats.size(); ++i) {
652 const size_t end = std::min(start +
m_window_size, data_size);
653 channel_result.window_positions.emplace_back(start, end);
654 }
655
657 channel_result.stat_classifications.reserve(ch_stats.size());
658 channel_result.level_counts.fill(0);
659
660 for (
double value : ch_stats) {
662 channel_result.stat_classifications.push_back(level);
663 channel_result.level_counts[static_cast<size_t>(level)]++;
664 }
665 }
666 }
667
668 return result;
669 }
StatisticalMethod m_method
StatisticalLevel classify_statistical_level(double value) const
Classify statistical value qualitatively.
bool m_classification_enabled
std::vector< double > percentile(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size, double percentile_value)
Arbitrary percentile per window via linear interpolation.
std::vector< double > variance(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size, bool sample_variance)
Variance per window.
std::vector< double > skewness(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Skewness (standardised third central moment) per window.
std::vector< double > kurtosis(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Excess kurtosis (fourth central moment - 3) per window.
std::vector< double > median(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Median per window via nth_element partial sort.
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.
StatisticalLevel
Qualitative classification of statistical values.