#include <chrono>
#include "datas.hpp"

int main(void) {
    
    auto st = std::chrono::system_clock::now();

    double w = 1.0;
    double b = 1.0;

    for (int _ = 0; _ < 100000; _++) {
        for (int i = 0; i < 442; i++) {
            auto x_i = x[i];
            auto y_i = y[i];

            auto y_hat = x_i * w + b;
            auto err = y_i - y_hat;
            auto w_rate = x_i;
            w = w + w_rate * err;
            b = b + 1 * err;
        }
    }

    printf("%lf %lf\n", w, b);

    auto ed = std::chrono::system_clock::now();

    std::chrono::duration<double> spent = ed - st;
    
    printf("%lf\n", spent.count());
    return 0;
}

이건 C++
Datas.hpp 에 데이터 있음


const startTime = new Date().getTime();

let w = 1.0;
let b = 1.0;

for (let i = 1; i <= 100000; i++{
    for (let i = 0; i < x.length; i++{
        const x_i = x[i];
        const y_i = y[i];
        
        const y_hat = x_i * w + b;
        const err = y_i - y_hat;
        const w_rate = x_i;
        
        w = w + w_rate * err;
        b = b + 1 * err;
    }
}
const endTime = new Date().getTime();
console.log(w + "" + b);
console.log(endTime - startTime);

이게 문제의 자스

데이터는 C++이랑 같고 위에 써놨는데 너무길어서 안올림


알고리즘은 차이가 없는데?