Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
This system can be represented using matrices and vectors in the form Ax = b
Exercise
Solve the following linear system: 2x 3y = 3 4x 5y + z = 7 2x -y -3z = 5
Determinants
Determinants
octave:15> det(A) ans = 4 octave:16> A(1,1)*A(2,2)-A(1,2)*A(2,1) ans = 4
Linear independence
Consider the following system:
Exercise
Download the incomplete script simpleReg.m and finish it by implementing the function S(x,y,beta). The output should be:
Linear regression
Linear regression
We can define this in matrix form too. Here,
where X is a matrix with Xi1 = 1 and Xi2 = xi , i.e. a column of ones followed by the column x.
Linear regression
Within Matlab, we simply write this as an overdetermined system X = y to obtain our parameter estimates by least squares. Matlab performs the minimization itself. This is the simple linear regression.
Exercise
Start by loading the file agevbp.txt from the course site. These are data comparing age (1st column) vs systolic blood pressure. 1. Plot age (x-axis) vs blood pressure (y-axis) 2. Build the two-column matrix X as defined above. 3. Solve X = y 4. Add the regression line to the plot
Quadratic regression
Exercises
1. Download the file qdata.txt of x,y pairs and perform a quadratic regression. Plot the data and the regression curve. 2. For the following data:
Hours Bacteria 1 25 2 38 3 58 4 89 5 135 6 206 7 315