From 8331cf653f6ac80ebb9c96c9c844803ce0278d43 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 11 Feb 2025 15:26:41 -0300 Subject: Split up code, worked on presentation slides. --- many_over.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 many_over.cpp (limited to 'many_over.cpp') diff --git a/many_over.cpp b/many_over.cpp new file mode 100644 index 0000000..5785ad3 --- /dev/null +++ b/many_over.cpp @@ -0,0 +1,67 @@ +#include +#include + +#include "fits.hpp" + +int main(int argc, char* argv[]) { + unsigned N = 80; + + int opt; + + while ((opt = getopt(argc, argv, "M:s:S:B:i:N:")) != -1) { + switch (opt) { + case 'N': + N = (unsigned)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}); + } + + Rng r; + + std::cout << std::setprecision(15); + + for (unsigned i = 0; i < 5; i++) { + Vector a₀ = Vector::Zero(N); + for (Real& aa : a₀) { + aa = r.variate(0, 2e-2); + } + + Vector a = stochasticGradientDescent(data, a₀, 10, 1e12); + + for (Real ai : a) { + std::cout << ai << " "; + } + std::cout << std::endl; + } + for (unsigned i = 0; i < 5; i++) { + Vector a₀ = Vector::Zero(N); + for (Real& aa : a₀) { + aa = r.variate(0, 5); + } + + Vector a = stochasticGradientDescent(data, a₀, 10, 1e12); + + for (Real ai : a) { + std::cout << ai << " "; + } + std::cout << std::endl; + } + + return 0; +} -- cgit v1.2.3-70-g09d2