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

Correlation and covariance computation functions. More...

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <functional>
#include <iterator>
#include <stdexcept>
#include <utility>
#include <vector>
#include "statcpp/basic_statistics.hpp"
Include dependency graph for correlation_covariance.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  statcpp
 
namespace  statcpp::detail
 Internal helper functions.
 

Functions

template<typename Iterator1 , typename Iterator2 >
double statcpp::population_covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
 Population covariance.
 
template<typename Iterator1 , typename Iterator2 >
double statcpp::population_covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, double mean_x, double mean_y)
 Population covariance with precomputed means.
 
template<typename Iterator1 , typename Iterator2 , typename Projection1 , typename Projection2 >
double statcpp::population_covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, Projection1 proj1, Projection2 proj2)
 Population covariance (projection version)
 
template<typename Iterator1 , typename Iterator2 >
double statcpp::sample_covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
 Sample covariance (unbiased covariance)
 
template<typename Iterator1 , typename Iterator2 >
double statcpp::sample_covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, double mean_x, double mean_y)
 Sample covariance with precomputed means.
 
template<typename Iterator1 , typename Iterator2 , typename Projection1 , typename Projection2 >
double statcpp::sample_covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, Projection1 proj1, Projection2 proj2)
 Sample covariance (projection version)
 
template<typename Iterator1 , typename Iterator2 >
double statcpp::covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
 Covariance (alias for sample_covariance)
 
template<typename Iterator1 , typename Iterator2 >
double statcpp::covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, double mean_x, double mean_y)
 Covariance with precomputed means (alias for sample_covariance)
 
template<typename Iterator1 , typename Iterator2 , typename Projection1 , typename Projection2 >
double statcpp::covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, Projection1 proj1, Projection2 proj2)
 Covariance (projection version, alias for sample_covariance)
 
template<typename Iterator1 , typename Iterator2 >
double statcpp::pearson_correlation (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
 Pearson correlation coefficient.
 
template<typename Iterator1 , typename Iterator2 >
double statcpp::pearson_correlation (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, double mean_x, double mean_y)
 Pearson correlation coefficient with precomputed means.
 
template<typename Iterator1 , typename Iterator2 , typename Projection1 , typename Projection2 >
double statcpp::pearson_correlation (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, Projection1 proj1, Projection2 proj2)
 Pearson correlation coefficient (projection version)
 
template<typename Iterator >
std::vector< double > statcpp::detail::compute_ranks (Iterator first, Iterator last)
 Helper function to compute ranks.
 
template<typename Iterator , typename Projection >
std::vector< double > statcpp::detail::compute_ranks (Iterator first, Iterator last, Projection proj)
 Rank computation (projection version)
 
template<typename Iterator1 , typename Iterator2 >
double statcpp::spearman_correlation (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
 Spearman's rank correlation coefficient.
 
template<typename Iterator1 , typename Iterator2 , typename Projection1 , typename Projection2 >
double statcpp::spearman_correlation (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, Projection1 proj1, Projection2 proj2)
 Spearman's rank correlation coefficient (projection version)
 
template<typename Iterator1 , typename Iterator2 >
double statcpp::kendall_tau (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
 Kendall's rank correlation coefficient (tau-b)
 
template<typename Iterator1 , typename Iterator2 , typename Projection1 , typename Projection2 >
double statcpp::kendall_tau (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, Projection1 proj1, Projection2 proj2)
 Kendall's rank correlation coefficient (projection version)
 
template<typename Iterator1 , typename Iterator2 , typename WeightIterator >
double statcpp::weighted_covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, WeightIterator weight_first)
 Weighted covariance.
 
template<typename Iterator1 , typename Iterator2 , typename WeightIterator , typename Projection1 , typename Projection2 >
double statcpp::weighted_covariance (Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, WeightIterator weight_first, Projection1 proj1, Projection2 proj2)
 Weighted covariance (projection version)
 

Detailed Description

Correlation and covariance computation functions.

Provides functions to measure relationships between variables including covariance, Pearson correlation coefficient, Spearman's rank correlation coefficient, and Kendall's rank correlation coefficient. Uses iterator-based interface compatible with various containers.

Definition in file correlation_covariance.hpp.