$darkmode
vstat
Bivariate statistics

Functions

template<std::floating_point T, std::input_iterator I, std::input_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, std::sized_sentinel_for< I > auto last1, J first2, F1 &&f1=F1{}, F2 &&f2=F2{})
 

Detailed Description

Methods for bivariate statistics.

Function Documentation

◆ accumulate()

requires concepts::arithmetic_projection<F1, std::iter_value_t<I> > and concepts::arithmetic_projection<F2, std::iter_value_t<J> > auto VSTAT_NAMESPACE::bivariate::accumulate ( first1,
std::sized_sentinel_for< I > auto  last1,
first2,
F1 &&  f1 = F1{},
F2 &&  f2 = F2{} 
)
inline

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.
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

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