41 using error::LUMIERA_ERROR_INVALID;
68 auto dat =
VecD{0,1,2,3,4,5};
71 CHECK (not isnil (all));
72 CHECK (dat.size() == all.size());
75 CHECK (i != all.end());
81 CHECK (
util::join(innr) ==
"1, 2, 3, 4"_expect);
82 CHECK (2 == innr.at(1));
97 auto dat =
VecD{4,2,5,8,6};
100 CHECK (2 == *rst.
begin());
101 CHECK (4 == rst.
size());
102 CHECK (5 == all.
size());
108 CHECK (
sdev (all, 5.0) == sqrt(20/(5-1)));
135 auto [socket,gradient
141 CHECK (socket == -1);
142 CHECK (gradient == 1);
143 CHECK (
util::join (predicted) ==
"0, 4, 2"_expect );
144 CHECK (
util::join (deltas) ==
"1, 1, -1"_expect );
145 CHECK (maxDelta == 1);
146 CHECK (correlation ==
"0.81649658"_expect );
147 CHECK (
sdev ==
"1.7320508"_expect );
159 auto dirt = [] {
return ranRange(-0.5,+0.5); };
160 auto fun = [&](
uint i){
auto x = double(i)/NUM_POINTS;
164 data.reserve (NUM_POINTS);
165 for (
uint i=0; i<NUM_POINTS; ++i)
166 data.push_back (fun(i) + dirt());
172 CHECK (roughEQ (gradient*NUM_POINTS, 1, 0.08));
173 CHECK (roughEQ (socket, -0.16, 0.3 ));
174 CHECK (correlation > 0.65);
Read-only view into a segment within a sequence of data.
void demonstrate_DataSpan()
void check_baseStatistics()
void check_TimeSeriesLinearRegression()
void check_wightedLinearRegression()
Helpers typically used while writing tests.
Building tree expanding and backtracking evaluations within hierarchical scopes.
DataSpan< double > lastN(VecD const &data, size_t n)
auto computeTimeSeriesLinearRegression(DataSpan< D > const &series)
Compute linear regression over a time series with zero-based indices.
std::vector< double > VecD
double sdev(DataSpan< D > const &data, D mean)
auto computeLinearRegression(DataSpan< RegressionPoint > const &points)
Compute simple linear regression with a single predictor variable (x).
double averageLastN(VecD const &data, size_t n)
double average(DataSpan< D > const &data)
std::vector< RegressionPoint > RegressionData
constexpr meta::enable_if< std::is_floating_point< F >, bool > roughEQ(F val, N target, F limit=ROUGH_PRECISION)
Implementation namespace for support and library code.
auto explore(IT &&srcSeq)
start building a IterExplorer by suitably wrapping the given iterable source.
double ranRange(double start, double bound)
Test runner and basic definitions for tests.
string join(COLL &&coll, string const &delim=", ")
enumerate a collection's contents, separated by delimiter.
bool isnil(lib::time::Duration const &dur)
Generating (pseudo) random numbers with controlled seed.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Support for generic statistics calculations.
A collection of frequently used helper functions to support unit testing.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...