Linear regression gradient step

Write codeHard30 minOpenAI and Anthropic style

Your task

Perform one full-batch gradient-descent update step for simple linear regression y = wx + b under mean-squared error. Given parallel lists xs and ys (n>=1 points), current weight w, bias b, and learning rate lr, compute predictions p_i = wx_i + b, the error e_i = p_i - y_i, the gradients dw = (2/n)sum(e_ix_i) and db = (2/n)sum(e_i), then return the updated parameters [w - lrdw, b - lr*db]. Round each returned parameter to 6 decimal places.

Examples

gd_step(xs: list[float], ys: list[float], w: float, b: float, lr: float) -> list[float]
Example 1
Inputgd_step([1, 2], [2, 4], 0, 0, 0.1)
Output[1, 0.6]