All pastes #444223 Raw Edit

Epanechnikov

public cpp v1 · immutable
·published 2007-04-17 08:05 UTC
rendered paste body
// calculates linear correlation (similar to r^2 but considering degree of absolute error rather than squared error)template<class T>T absolute_linear_correlation(const vector<T> &y, const vector<T> &yhat){	T ybar = sum(y) / y.size();	T ts = sum(abs(y - ybar));	T rs = sum(abs(y - yhat));	T rv = ts ? (ts - rs) / ts : (rs ? 1 : 0);	return rv;}