0

I was going through the vector representation for linear regression. The error has been defined as

$$ Error = {(y_i - x_i^tw)}^2 $$

where $y_i$ is a scalar, $x$ is a $n \times 1$ vector and $w$ is also a $n \times 1$ vector.

On the next line, it has been simplified to

$$ Error = {y_i}^2 -2w^tx_iy_i + w^tx_ix_i^tw $$

Can someone explain how did we reach the second notion through a series of steps?

Arnaldo
  • 21,342
Sam
  • 171

1 Answers1

0

Since $x_i\cdot w$ is a scalar,$$(y_i-x_i\cdot w)^2=y_i^2-2x_i\cdot wy_i+(x_i\cdot w)(x_i\cdot w).$$The rest is an abuse of notation identifying $x_i\cdot w$ with $x_i^tw$ and $w^tx_i$.

J.G.
  • 115,835