While going through page 1 of Lecture 24: Weighted and Generalized Least Squares [PDF], I got the following questions. Weighted sum of squares is defined as below: $$ \sum_{i = 0}^{n}{w_i(Y_i - X_ib)^2}$$ And this could be written in matrix notation as follows $$(Y−Xb)'W(Y−Xb)$$
Only thing I did not get is how $W$ (weights) got into the middle? And why should it be a diagonal matrix?
I get that $\sum_{}x^2$ could be written as $X^T * X $. But how $\sum_{}wx^2$ is written as $X^TWX$ , any clue?