0% found this document useful (0 votes)
950 views

MAT523 Project PDF

The document provides instructions for a mini project assignment involving modeling real data using mathematical curves. Students are asked to: 1) Obtain real data from the web with at least 20 data points comparing two variables. 2) Use linear, quadratic, cubic, and higher degree models to find the best fit curve for the data using least squares regression. 3) For each model, calculate the equation of the curve, error vector, error magnitude, and plot the data, fit curve, and residuals. 4) Compare the models and determine which provides the best approximation, justifying the selection.

Uploaded by

Muhd Iqbal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
950 views

MAT523 Project PDF

The document provides instructions for a mini project assignment involving modeling real data using mathematical curves. Students are asked to: 1) Obtain real data from the web with at least 20 data points comparing two variables. 2) Use linear, quadratic, cubic, and higher degree models to find the best fit curve for the data using least squares regression. 3) For each model, calculate the equation of the curve, error vector, error magnitude, and plot the data, fit curve, and residuals. 4) Compare the models and determine which provides the best approximation, justifying the selection.

Uploaded by

Muhd Iqbal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MAT523

MINI PROJECT ASSIGNMENT

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

3. For each model:

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.

c) Plot the graphs:


i) Points of scattered data and best fit curve that you have
calculated.
ii) Graph of residuals (error vector) around the x-axis (y=0)

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:

a) Introduction :Brief description of data (attach the data as published at


the web in the appendix)
b) Implementation of each model including the matrix representation, normal
equations, least square solution, equation of the best fit curve, the error
vector, norm of the error vector,
c) graphs.
d) Analysis and conclusion including graph of the scattered data and
the best fit curves

The assignment will be done in 2 stages

1) Stage 1: Introduction and implementation

2) Stage 2: graph of the scattered data and the best


fit curves

~namn~
Sample calculation:

Note : All coding should be attached in the appendix.

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 
  

Its normal equation is


 5 75  a  =  26.5 
     
75 1375  b  442.5  Matrix MTy
Matrix
MTM  11 -3 
 
* 
The least squares solution is v = 
a  =  10 50   26.5  =  2.600 
      
 b   -3 1 
 442.5  0.1800 

 50 250 

Matrix (MTM)-1 MTy

 the best fit linear curve is y = 2.6 + 0.18x

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 

 the best fit quadratic curve is y = 2.8 + 0.145x + 0.00119x2

3.5  3.5548  -0.0548 


4.5  4.3690   0.1310 
     
Error vector e = e = y - M v = 5.2  - 5.2428  =
   
*

    -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 

 the best fit cubic curve is y = 2 + 0.3x – 0.0014x2 + 0.00031x3

3.5  3.1888  0.3112 


4.5  3.9100  0.5900 
     
Error vector e = e = y - M v = 5.2  - 4.3962  =
   
*

    0.8038 
6.1  4.8800  1.2200 
     
     
7.2  5.5938  1.6062 
     
error magnitude ||e|| = 2.2714

END OF ASSIGNMENT 1

attach all graphs here


 graph of best fit curve against its observed data
 graph of the error vector against x values

Analysis and Conclusion

Based on the fivemodels above, the following error magnitudes in the approximation are
obtained.

Types of Best Fit Curve Error magnitude


Linear 0.20000
Quadratic 0.16954
Cubic 2.2714

 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.

attach graph here

the projected graph of best fit curve against its observed data that produces the
least error

APPENDIX
All coding, output.

~namn~

You might also like