MAT523 Project PDF
MAT523 Project PDF
1. Obtain REAL data – from the web (at least 20 data points) comparing two variables
i.e. x and y which have some relationship between them.
2. Use mathematical models to find the best fit curve for the data
Example
Linear model
Quadratic model
Cubic Model and
model of higher degree
a) Find the equation of the curve by using the least squares method.
b) Find the error vector and the magnitude of this error vector.
4. By comparing the models, determine which gives the best approximation for your set of
data. Give reasons for your answer.
NOTE
The mini project assignment should follow the sample attached. It must include the
following:
~namn~
Sample calculation:
The following data (suppose this is the data obtained) from company XX shows the
relationship between the number of sales representatives and the annual sales. (Data
attached in the appendix)
X 5 10 15 20 25
(No of sales
representatives)
Y 3.5 4.3 5.2 6.1 7.2
(Annual sales)
Implementation
Linear model: y = a + bx
The data generates a system of linear equations with the matrix representation as below:
1 5
3.5
1 10 4.5
1 15 v = 5.2
1 20 6.1
Matrix M
Matrix y, all the dependent variables
1 25 7.2
3.5 3.5000 0.
4.5 4.4000 0.1000
= 5.2 - 5.3000 =
*
Error vector e = y - M v
-0.1000
6.1 6.2000 -0.1000
7.2 7.1000 0.1000
Matrix y - Mv
||e|| = 0.20000
~namn~
Quadratic model: y = a + bx + cx2
The matrix representation of the above system is
1 5 25
3.5
1 10 100 4.5
1 15 225 v = 5.2
1 400 6.1
20
1 625 7.2
25
and its normal equation is
5 75 1375 a 26.5
75 1375 28125 b = 442.5
1375 28125 611875
c 8647.5
The least squares solution is
23 -33 1
5 50 50
a 26.5 2.80
v * = b = -33 187 -3
442.5 =
0.145
50
1750 875
c 1 -3
1 8647.5 0.00119
50 875 8750
-0.0428
6.1 6.1760 -0.0760
7.2 7.1688 0.0312
||e|| = 0.16954
Cubic model y = a + bx + cx2 + dx3
The matrix representation of the above system is
1 5 25 125
3.5
1 10 100 1000 4.5
1 15 225 3375 v = 5.2
1 8000 6.1
20 400
1 15625 7.2
25 625 a
and its normal equation is b
5 75 1375 28125 c 26.5
75 1375 28125 611875 442.5
d =
1375 28125 611875 13828125 8647.5
28125 320546875 183790.
611875 13828125
~namn~
The least squares solution is
a 121 -37 11 -7
5
b 6 25 750
c -37 521 -17 59 26.5 2.0
22500 442.5 0.30
v = d = 6
* 315 140 =
8647.5 -0.014
11 -17 319 -1
183790. 0.00031
25 5000
140 35000
-7 1
59 -1
750 22500 5000 225000
0.8038
6.1 4.8800 1.2200
7.2 5.5938 1.6062
error magnitude ||e|| = 2.2714
END OF ASSIGNMENT 1
Based on the fivemodels above, the following error magnitudes in the approximation are
obtained.
the best fit curves in this case which will give the best approximation is the quadratic best
fit curve because it has the minimum error in terms of its magnitude.
the projected graph of best fit curve against its observed data that produces the
least error
APPENDIX
All coding, output.
~namn~