mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
vectorUtils_test.cpp
Go to the documentation of this file.
1/** \file vectorUtils_test.cpp
2 * \brief Tests vector statistics used by HCI preprocessing.
3 */
4#include "../../catch2/catch.hpp"
5
7
8#include <vector>
9
10namespace unitTest::math_vectorUtils_test
11{
12
13/** \brief Verifies the sample-variance overload used by HCI time-series normalization.
14 *
15 * \ingroup vectorUtils_unit_tests
16 */
17TEST_CASE( "vectorVariance computes sample variance", "[math::vectorUtils::vectorVariance]" )
18{
19 const std::vector<double> values{ 1.0, 3.0 };
20
21 REQUIRE( mx::math::vectorVariance( values ) == Approx( 2.0 ) );
22 REQUIRE( mx::math::vectorVariance( values, 0.0 ) == Approx( 10.0 ) );
23}
24
25} // namespace unitTest::math_vectorUtils_test
TEST_CASE("vectorVariance computes sample variance", "[math::vectorUtils::vectorVariance]")
Verifies the sample-variance overload used by HCI time-series normalization.
valueT vectorVariance(const valueT *vec, size_t sz, valueT mean)
Calculate the variance of a vector relative to a supplied mean value.
Header for the std::vector utilities.