var known_y = [1, 2, 3, 4]; var known_x = [5.2, 5.7, 5.0, 4.2]; var lr = linearRegression(known_y, known_x); // now you have: // lr.slope // lr.intercept // lr.r2