Defined in header <scicpp/core.hpp>
Compute the median.
Compute the median of an array using only the values satisfying the filter predicate.
Compute the median of an array.
Compute the median of an array, , ignoring NaNs.
#include <scicpp/core.hpp>
#include <cstdio>
int main()
{
const std::array a{-1., 1., 2., 3.};
// Compute the mean of the array
auto m = scicpp::stats::median(a);
// Compute the mean of the positive values of the array
auto m_pos = scicpp::stats::median(a, [](auto x) { return x >= 0; });
printf("m = %f, m_pos = %f\n", m, m_pos);
}