statcpp
C++17 Header-Only Statistics Library
Loading...
Searching...
No Matches
Namespaces | Functions
nonparametric_tests.hpp File Reference

Nonparametric test functions. More...

#include "statcpp/basic_statistics.hpp"
#include "statcpp/order_statistics.hpp"
#include "statcpp/continuous_distributions.hpp"
#include "statcpp/discrete_distributions.hpp"
#include "statcpp/parametric_tests.hpp"
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <stdexcept>
#include <utility>
#include <vector>
Include dependency graph for nonparametric_tests.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  statcpp
 

Functions

template<typename Iterator >
std::vector< double > statcpp::compute_ranks_with_ties (Iterator first, Iterator last)
 Compute ranks with tie handling.
 
std::vector< std::size_t > statcpp::compute_tie_groups (const std::vector< double > &sorted_values)
 Compute tie group sizes from sorted data.
 
template<typename Iterator >
test_result statcpp::shapiro_wilk_test (Iterator first, Iterator last)
 Perform Shapiro-Wilk test.
 
template<typename Iterator >
test_result statcpp::lilliefors_test (Iterator first, Iterator last)
 Perform Lilliefors test for normality.
 
template<typename Iterator >
test_result statcpp::ks_test_normal (Iterator first, Iterator last)
 Perform Kolmogorov-Smirnov test for normality (deprecated)
 
test_result statcpp::levene_test (const std::vector< std::vector< double > > &groups)
 Perform Levene test (homogeneity of variance test)
 
test_result statcpp::bartlett_test (const std::vector< std::vector< double > > &groups)
 Perform Bartlett test (homogeneity of variance test)
 
template<typename Iterator >
test_result statcpp::wilcoxon_signed_rank_test (Iterator first, Iterator last, double mu0=0.0, alternative_hypothesis alt=alternative_hypothesis::two_sided)
 Perform Wilcoxon signed-rank test (one-sample)
 
template<typename Iterator1 , typename Iterator2 >
test_result statcpp::mann_whitney_u_test (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, alternative_hypothesis alt=alternative_hypothesis::two_sided, bool correct=true)
 Perform Mann-Whitney U test (two-sample)
 
test_result statcpp::kruskal_wallis_test (const std::vector< std::vector< double > > &groups)
 Perform Kruskal-Wallis test (k-sample)
 
test_result statcpp::fisher_exact_test (std::uint64_t a, std::uint64_t b, std::uint64_t c, std::uint64_t d, alternative_hypothesis alt=alternative_hypothesis::two_sided)
 Perform Fisher's exact test (2x2 contingency table)
 

Detailed Description

Nonparametric test functions.

Provides distribution-free statistical tests including Wilcoxon test, Mann-Whitney U test, and Kruskal-Wallis test. Also includes normality tests (Shapiro-Wilk, Kolmogorov-Smirnov) and homogeneity of variance tests (Levene, Bartlett).

Note
Tie detection: Tied values are identified using exact floating-point equality (operator==). This is appropriate for observed data values (integers, fixed-precision decimals) where identical values have identical bit representations. This is consistent with R's behavior. Users should avoid passing values computed from floating-point arithmetic (e.g., sqrt(2)*sqrt(2) vs 2.0) as they may not be recognized as ties.

Definition in file nonparametric_tests.hpp.