#include #include "Least_sqrs_est.h" int main() { std::cout.precision( 16 ); double y[10]{ 5.7344, 6.7585, 6.4353, 7.9155, 8.4797, 8.7731, 9.6916, 10.5857, 12.0946, 12.5924 }; Linear_estimator lin_data_jit{}; Linear_estimator lin_data{}; Quadratic_estimator quad_data_jit{}; Quadratic_estimator quad_data{}; std::cout << "Data: " << std::endl << " "; for ( int k{0}; k < 9; ++k ) { std::cout << y[k] << ", "; lin_data_jit.add( y[k] ); lin_data.add( y[k] ); quad_data_jit.add( y[k] ); quad_data.add( y[k] ); } std::cout << y[9] << std::endl; double ylin{ lin_data_jit.add( y[9], 0.5 ) }; lin_data.add( ylin ); double yquad{ quad_data_jit.add( y[9], 0.5 ) }; quad_data.add( yquad ); std::cout << "Corrected linear value dealing with jitter: " << ylin << std::endl; std::cout << "Corrected quadratic value dealing with jitter: " << yquad << std::endl; std::cout << "Linear estimators with jitter" << std::endl; std::cout << "Best estimator of current value: " << lin_data_jit.current() << std::endl; std::cout << "Best estimator of next value: " << lin_data_jit.next() << std::endl; std::cout << "Best estimator of change per step: " << lin_data_jit.change_per_period() << std::endl; std::cout << "Best estimator of average value over the last step: " << lin_data_jit.average_last_period() << std::endl; std::cout << "Best estimator of average value over the next step: " << lin_data_jit.average_next_period() << std::endl; std::cout << "Best estimator of a zero: " << lin_data_jit.zero() << std::endl; std::cout << std::endl; std::cout << "Linear estimators" << std::endl; std::cout << "Best estimator of current value: " << lin_data.current() << std::endl; std::cout << "Best estimator of next value: " << lin_data.next() << std::endl; std::cout << "Best estimator of change per step: " << lin_data.change_per_period() << std::endl; std::cout << "Best estimator of average value over the last step: " << lin_data.average_last_period() << std::endl; std::cout << "Best estimator of average value over the next step: " << lin_data.average_next_period() << std::endl; std::cout << "Best estimator of a zero: " << lin_data.zero() << std::endl; std::cout << std::endl; std::cout << "Quadratic estimators with jitter" << std::endl; std::cout << "Best estimator of current value: " << quad_data_jit.current() << std::endl; std::cout << "Best estimator of next value: " << quad_data_jit.next() << std::endl; std::cout << "Best estimator of change per step: " << quad_data_jit.change_per_period() << std::endl; std::cout << "Best estimator of change per step per step: " << quad_data_jit.change_per_period_per_period() << std::endl; std::cout << "Best estimator of average value over the last step: " << quad_data_jit.average_last_period() << std::endl; std::cout << "Best estimator of average value over the next step: " << quad_data_jit.average_next_period() << std::endl; std::cout << "Best estimator of a extremum: " << quad_data_jit.extremum() << std::endl; std::cout << std::endl; std::cout << "Quadratic estimators" << std::endl; std::cout << "Best estimator of current value: " << quad_data.current() << std::endl; std::cout << "Best estimator of next value: " << quad_data.next() << std::endl; std::cout << "Best estimator of change per step: " << quad_data.change_per_period() << std::endl; std::cout << "Best estimator of change per step per step: " << quad_data.change_per_period_per_period() << std::endl; std::cout << "Best estimator of average value over the last step: " << quad_data.average_last_period() << std::endl; std::cout << "Best estimator of average value over the next step: " << quad_data.average_next_period() << std::endl; std::cout << "Best estimator of a extremum: " << quad_data.extremum() << std::endl; std::cout << std::endl; return 0; }