# Formula for weighted simple linear regression

This wiki page Simple linear regression has formulas to calculate $\alpha$ and $\beta$. Could anyone tell me how to derive the formulas in weighted case?

Think of ordinary least squares (OLS) as a "black box" to minimize

$$\sum_{i=1}^n (y_i - (\alpha 1 + \beta x_i))^2$$

for a data table whose $i^\text{th}$ row is the tuple $(1, x_i, y_i)$.

When there are weights, necessarily positive, we can write them as $w_i^2$. By definition, weighted least squares minimizes

$$\sum_{i=1}^n w_i^2(y_i - (\alpha 1 + \beta x_i))^2$$

$$=\sum_{i=1}^n (w_i y_i - (\alpha w_i + \beta w_i x_i))^2 .$$

But that's exactly what the OLS black box is minimizing when given the data table consisting of the "weighted" tuples $(w_i, w_i x_i, w_i y_i)$. So, applying the OLS formulas to these weighted tuples gives the formulas you seek.