Systems of linear equations to calculate $\alpha$ and $\beta$

2k Views Asked by At

Point $1$: When there is $1$ car passing the road, the average speed is $50$ km/h.

Point $2$: When there are $5$ cars passing the road, the average speed is $45$ km/h.

Point $3$: When there are $12$ cars passing the road, the average speed is $38$ km/h.

A traffic engineering company decides to model the average speed (shown by $u$) as a linear function of the number of cars (shown by $n$). So we want to have

$u(n)=\alpha+\beta n$ .

  • Using Point $1$ , Point $2$ and Point $3$ information: write a system of linear equations to calculate $\alpha$ and $\beta$ using all three points; i.e. we will have three equations with two unknowns.
4

There are 4 best solutions below

0
On

You are given the equation, and also a few data points: for each of the three scenarios, you have the number of cars ($n$) and the observed average speed ($u(n)$).

So your three equations are \begin{align*} 50 &= \alpha + \beta\\ 45 &= \alpha + 5\beta\\ 38 &= \alpha + 12\beta \end{align*}

  1. Can you write this in matrix form, i.e. can you write down a matrix $M$ and vector $b$ such that $$M\left[\begin{array}{c}\alpha\\\beta\end{array}\right] = b?$$

  2. An overconstrained system of equations does not always have a solution. But you can always find an $\alpha$ and $\beta$ that minimizes the error, i.e. minimizes the square residual: $$\min_{\alpha, \beta}\quad \left\|M\left[\begin{array}{c}\alpha\\\beta\end{array}\right] - b\right\|^2.$$ Finding this minimizier is called solving the least squares problem. Do you need more help for how to solve it here?

0
On

$\left[\begin{array}{cc}1 & 1\\ 1 & 5\\ 1 & 12\end{array}\right]\left[\begin{array}{c}\alpha\\ \beta\end{array}\right] = \left[\begin{array}{c}50\\45\\38\end{array}\right]$

2
On

$$ \left(% \begin{array}{cc} 1 & 1 \\ 1 & 5 \\ 1 & 12 \end{array}\right) \left(% \begin{array}{c} \alpha \\ \\ \beta \end{array}\right) = \left(% \begin{array}{cc} 50 \\ 45 \\ 38 \end{array}\right)\,, \qquad\qquad \left(% \begin{array}{ccc} 1 & 1 & 1 \\ 1 & 5 & 12 \end{array}\right) \left(% \begin{array}{cc} 1 & 1 \\ 1 & 5 \\ 1 & 12 \end{array}\right) \left(% \begin{array}{c} \alpha \\ \\ \beta \end{array}\right) = \left(% \begin{array}{ccc} 1 & 1 & 1 \\ 1 & 5 & 12 \end{array}\right) \left(% \begin{array}{cc} 50 \\ 45 \\ 38 \end{array}\right) $$

$$ \left(% \begin{array}{cc} 3 & 18 \\ 18 & 169 \end{array}\right) \left(% \begin{array}{c} \alpha \\ \beta \end{array}\right) = \left(% \begin{array}{cc} 133 \\ 731 \end{array}\right)\,, \qquad\qquad \left\{% \begin{array}{rcrcl} 3\alpha & + & 18\beta & = & 133 \\ 18\alpha & + & 169\beta & = & 731 \end{array}\right. $$

$$ \alpha = {9,319 \over 183} = 50.9234\ldots\qquad\qquad \beta = -\,{67 \over 61} = -1.098\ldots $$

This is the best compromise !!!. How about the method ?. Let's assume we have a system, for an unknown vector $\vec{v}$, ${\bf A}\vec{v} = \vec{b}$ which 'we can not satisfy'. ${\bf A}$ is a given matrix and $\vec{b}$ is a given vector. Then, we are glad whenever we keep ${\bf A}\vec{v}$ as close as possible to $\vec{b}$. It means that we minimize ${\cal F} \equiv\left({\bf A}\vec{v} - \vec{b}\right)^{2}$:

$$ {\cal F} = \left(\vec{v}^{\rm T}{\bf A}^{\rm T} - \vec{b}^{\rm T}\right) \left({\bf A}\vec{v} - \vec{b}\right) = \vec{v}^{\rm T}{\bf A}^{\rm T}{\bf A}\vec{v} - \vec{v}^{\rm T}{\bf A}^{\rm T}\vec{b} - \vec{b}^{\rm T}{\bf A}\vec{v} + \vec{b}^{\rm T}\vec{b} $$

$$ 0 = \delta{\cal F} = \delta\vec{v}^{\rm T} \left({\bf A}^{\rm T}{\bf A}\vec{v} - {\bf A}^{\rm T}\vec{b}\right) + \left(\vec{v}^{\rm T}{\bf A}^{\rm T}{\bf A} - \vec{b}^{\rm T}{\bf A}\right)\delta\vec{v} $$

$$ \mbox{which yields}\quad {\bf A}^{\rm T}{\bf A}\vec{v} = {\bf A}^{\rm T}\,\vec{b} $$

0
On

You have three equations u(n) = alpha + beta * n and three data points. Since the model is not perfect (your three points do not perfectly align), you can define an error function which could write

Error = (alpha + beta - 50)^2 + (alpha + 5 * beta - 45)^2 + (alpha + 12 * n - 38)^2

This Error function represents the sum of squares of the vertical distances between the exact speeds and the approximate speeds; this is the principle of linear least square fit method.

In order to minimize the errors, derive Error with respect to alpha and to beta and set them to zero. This will lead to two linear equations for the two unknowns alpha and beta.

Are you able to continue with this ?