Premium problem167. OLS Beta and R-Squared via Least Squares

Medium Locked

Regress y on x with an intercept and return (alpha, beta, r_squared), where r_squared = 1 - SS_res / SS_tot.

Input

x = [1. 2. 3. 4.]
y = [2.1 3.9 6.2 7.8]

Output

(0.1500000000000017, 1.9399999999999993, 0.9956613756613757)

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)