You are on page 1of 7

DCEE23 – Numerical Methods and Analysis

Practical Examination – Linear and Polynomial Regression

Objectives:
At the end of the exercise, the students should be able to:
 compute linear regressions using matrix operations in Google Colab.
 compute polynomial regressions using matrix calculations in Google Colab.
 perform linear regression analysis by computing matrices and plotting the results
in Google Colab.
 familiarize students with the process of computing polynomial regressions
through matrix operations and generating visual plots using Google Colab.
Materials:
 Android phone or computer with internet access
 CvSU-provided Google account (to access Google Colab)

Instruction:
Solve the following problems analytically (manual computation) and by creating a
code on Google Colab. You will be required to plot data points and the linear /
polynomial model equation. Each problem must have an analytical solution and the
code used in solving the given problem. You can put your solution and coding below the
“Analytical Solution:” and “Coding on Google Colab:” titles, respectively.
Note: You will be using Google Colab to perform matrix operation to find the
determinants, coefficients and the model equation, and plotting data along with the
model equation.
DCEE23 – Numerical Methods and Analysis

Problem 1:
A study was done to compare the speed x (in miles per hour) with the mileage y
(in miles per gallon) of an automobile. The results are shown in the table.
Fit a linear model and a quadratic model for the data. Determine which model
better fits the data. Plot the data along with the linear and quadratic model.
DCEE23 – Numerical Methods and Analysis

Analytical Solution
DCEE23 – Numerical Methods and Analysis

Coding on Google Colab:


We can see here that
Linear Model the best fit model is
the quadratic model
because the line is
closer to the value
than in the linear
model.

Quadratic Model
DCEE23 – Numerical Methods and Analysis

Problem 2:
A basketball is dropped from a height of about 5.25 feet. The height of the
basketball is recorded 23 times at intervals of about 0.02 second. The results are shown
in the table.
Fit a linear model and a quadratic model for the data. Determine which model
better fits the data. Plot the data along with the linear and quadratic model.
DCEE23 – Numerical Methods and Analysis

Analytical Solution:

Coding on Google Colab:


DCEE23 – Numerical Methods and Analysis

Linear Model

Same as problem number 1,


although the linear model that
we can see here is also near the
value, the best-fit model is the
quadratic model because the line
is closer to the value than in the
linear model.

Quadratic Model

You might also like