#include #include #include "fits.hpp" int main(int argc, char* argv[]) { unsigned Nend = 1; unsigned nBatches = 5; Real σ = 0.2; Real iniVar = 0.0; long unsigned maxSteps = 1e12; int opt; while ((opt = getopt(argc, argv, "s:S:B:i:N:")) != -1) { switch (opt) { case 'N': Nend = (unsigned)atof(optarg); break; case 's': σ = atof(optarg); break; case 'S': maxSteps = (long unsigned)atof(optarg); break; case 'B': nBatches = (unsigned)atof(optarg); break; case 'i': iniVar = atof(optarg); break; default: exit(1); } } std::string firstline; std::getline(std::cin, firstline); std::stringstream ss; ss << firstline; Data data; while (!ss.eof()) { Real x, y; ss >> x; ss >> y; data.push_back({x,y}); } unsigned M = data.size(); Rng r; std::cout << std::setprecision(15); for (unsigned N = 1; N <= M; N++) { Vector a = underSolve(data, N); for (Real ai : a) { std::cout << ai << " "; } std::cout << std::endl; } for (unsigned N = Nend; N > M; N--) { Vector a₀ = Vector::Zero(N); for (Real& aa : a₀) { aa = r.variate(0, iniVar); } Vector a = stochasticGradientDescent(data, a₀, nBatches, maxSteps); for (Real ai : a) { std::cout << ai << " "; } std::cout << std::endl; } return 0; }