Goldberg Variations
New member
- Joined
- Feb 24, 2012
- Messages
- 16
Hey! I'm working on a question where you are supposed to use the Least Squares Method to be used on a line.
I don't have the correct answer to this question but would appreciate it if anyone here could double check my answer or tell me if I've done something wrong.
Translated to English the question says the following:
"Adjust the line y = a + bx according to the Least Squares Method with the following data: "
\(\displaystyle x|1\hspace{1 mm}2\hspace{1 mm}3\hspace{1 mm}4\)
\(\displaystyle \overline{y|1\hspace{1 mm}1\hspace{1 mm}0\hspace{1 mm}-1}\)
My solution:
\(\displaystyle y=a+bx\implies y=bx+a\)
\(\displaystyle \begin{pmatrix}
1& 1\\
2& 1\\
3& 1\\
4& 1
\end{pmatrix}
\begin{pmatrix}
a\\
b
\end{pmatrix}
=
\begin{pmatrix}
1\\
1\\
0\\
-1
\end{pmatrix}
\hspace{10 mm} A\bar{x}=\bar{y}
\)
Normal Equation gives:
\(\displaystyle A^TA\bar{x}=A^T\bar{y}\)
So:
\(\displaystyle \begin{pmatrix}
1 & 2& 3 & 4\\
1 & 1 &1 & 1
\end{pmatrix}
\begin{pmatrix}
1 & 1\\
2 & 1\\
3 & 1\\
4 & 1
\end{pmatrix}
\begin{pmatrix}
a\\
b
\end{pmatrix}
=
\begin{pmatrix}
1 & 2& 3 & 4\\
1 & 1 &1 & 1
\end{pmatrix}
\begin{pmatrix}
1\\
1\\
0\\
-1
\end{pmatrix}\implies\)
\(\displaystyle \implies\begin{pmatrix}
30 & 10\\
10 & 4
\end{pmatrix}
\begin{pmatrix}
a\\
b
\end{pmatrix}
=
\begin{pmatrix}
-1\\
1
\end{pmatrix}\)
Gauss Elimination:
\(\displaystyle 30a + 10b = -1\)
\(\displaystyle 10a + 4b = 1\)
Reduce Second row three times to first row
\(\displaystyle -2b = -4\)
\(\displaystyle 10a + 4b = 1\)
b = 2, now solving for a
\(\displaystyle 10a = 1 - 4*2=1-8=-7\implies a=\dfrac{-7}{10}\)
Which gives me my answer:
\(\displaystyle y=2+\dfrac{-7}{10}x\)
Am I on the right path? Thanks in advance for any input.
I don't have the correct answer to this question but would appreciate it if anyone here could double check my answer or tell me if I've done something wrong.
Translated to English the question says the following:
"Adjust the line y = a + bx according to the Least Squares Method with the following data: "
\(\displaystyle x|1\hspace{1 mm}2\hspace{1 mm}3\hspace{1 mm}4\)
\(\displaystyle \overline{y|1\hspace{1 mm}1\hspace{1 mm}0\hspace{1 mm}-1}\)
My solution:
\(\displaystyle y=a+bx\implies y=bx+a\)
\(\displaystyle \begin{pmatrix}
1& 1\\
2& 1\\
3& 1\\
4& 1
\end{pmatrix}
\begin{pmatrix}
a\\
b
\end{pmatrix}
=
\begin{pmatrix}
1\\
1\\
0\\
-1
\end{pmatrix}
\hspace{10 mm} A\bar{x}=\bar{y}
\)
Normal Equation gives:
\(\displaystyle A^TA\bar{x}=A^T\bar{y}\)
So:
\(\displaystyle \begin{pmatrix}
1 & 2& 3 & 4\\
1 & 1 &1 & 1
\end{pmatrix}
\begin{pmatrix}
1 & 1\\
2 & 1\\
3 & 1\\
4 & 1
\end{pmatrix}
\begin{pmatrix}
a\\
b
\end{pmatrix}
=
\begin{pmatrix}
1 & 2& 3 & 4\\
1 & 1 &1 & 1
\end{pmatrix}
\begin{pmatrix}
1\\
1\\
0\\
-1
\end{pmatrix}\implies\)
\(\displaystyle \implies\begin{pmatrix}
30 & 10\\
10 & 4
\end{pmatrix}
\begin{pmatrix}
a\\
b
\end{pmatrix}
=
\begin{pmatrix}
-1\\
1
\end{pmatrix}\)
Gauss Elimination:
\(\displaystyle 30a + 10b = -1\)
\(\displaystyle 10a + 4b = 1\)
Reduce Second row three times to first row
\(\displaystyle -2b = -4\)
\(\displaystyle 10a + 4b = 1\)
b = 2, now solving for a
\(\displaystyle 10a = 1 - 4*2=1-8=-7\implies a=\dfrac{-7}{10}\)
Which gives me my answer:
\(\displaystyle y=2+\dfrac{-7}{10}x\)
Am I on the right path? Thanks in advance for any input.