m t
J(θ) = Σw[i] [h(θ)x[i] - y[i] ]**2 = (Xθ - y) w (Xθ - Y)
i=1
t
I think it is wrong it should be equal to w (Xθ - y) (Xθ - Y)
because we can not change the order of matrix in multiplication.