vstat
Loading...
Searching...
No Matches
Bivariate statistics

Functions

template<std::floating_point T, nan_policy Policy = nan_policy::propagate, std::random_access_iterator I, std::random_access_iterator J, typename F1 = std::identity, typename F2 = std::identity>
requires concepts::arithmetic_projection<F1, std::iter_value_t<I>>
and concepts::arithmetic_projection< F2, std::iter_value_t< J > > auto accumulate (I first1, I last1, J first2, F1 &&f1=F1 {}, F2 &&f2=F2 {}) noexcept -> std::conditional_t< Policy==nan_policy::omit, std::pair< bivariate_statistics, std::size_t >, bivariate_statistics >
 
template<std::floating_point T, nan_policy Policy = nan_policy::propagate, std::random_access_iterator I, std::random_access_iterator J, std::random_access_iterator K, typename F1 = std::identity, typename F2 = std::identity>
requires concepts::arithmetic_projection<F1, std::iter_value_t<I>>
and concepts::arithmetic_projection< F2, std::iter_value_t< J > > and std::is_arithmetic_v< std::iter_value_t< K > > auto accumulate (I first1, I last1, J first2, K first3, F1 &&f1=F1 {}, F2 &&f2=F2 {}) noexcept -> std::conditional_t< Policy==nan_policy::omit, std::pair< bivariate_statistics, std::size_t >, bivariate_statistics >
 

Detailed Description

Methods for bivariate statistics.

Function Documentation

◆ accumulate()

template<std::floating_point T, nan_policy Policy = nan_policy::propagate, std::random_access_iterator I, std::random_access_iterator J, typename F1 = std::identity, typename F2 = std::identity>
requires concepts::arithmetic_projection<F1, std::iter_value_t<I>>
and concepts::arithmetic_projection< F2, std::iter_value_t< J > > auto accumulate ( first1,
last1,
first2,
F1 &&  f1 = F1 {},
F2 &&  f2 = F2 {} 
) -> std::conditional_t<Policy == nan_policy::omit, std::pair<bivariate_statistics, std::size_t>, bivariate_statistics>
inlinenoexcept

Compute bivariate statistics from two sequences of values. The values can be provided directly or via a projection method.

Template Parameters
TThe scalar value type underlying the eve::wide<T> SIMD type used to compute the stats.
Policynan_policy::propagate (default): a non-finite value poisons the whole result. nan_policy::omit: positions where either raw input is non-finite are skipped (zero-weighted) instead, and the count of skipped pairs is additionally returned.
Parameters
first1The begin iterator for the first sequence
last1The end iterator for the first sequence
first2The begin iterator for the second sequence
f1A projection mapping std::iter_value_t<I> to a scalar value
f2A projection mapping std::iter_value_t<J> to a scalar value
Returns
nan_policy::propagate: the accumulated bivariate statistics. nan_policy::omit: the accumulated bivariate statistics over finite pairs, and the count of skipped (non-finite) pairs.

Example

float x[] = { 1., 1., 2., 6. };
float y[] = { 2., 4., 3., 1. };
auto stats = bivariate::accumulate<float>(std::begin(x), std::end(x),
std::begin(y)); std::cout << stats << "\n";
// results
count: 4
sum_x: 10
ssr_x: 17
mean_x: 2.5
variance_x: 4.25
sample variance_x: 5.66667
sum_y: 10
ssr_y: 5
mean_y: 2.5
variance_y: 1.25
sample variance_y: 1.66667
correlation: -0.759257
covariance: -1.75
sample covariance: -2.33333