70 likes | 140 Views
COMP 116: Introduction to Scientific Programming . Lecture 13: So l ong Matrices. Regression recap. Linear Regression basics. Hypothesize a model y= mx+c Set it up as a linear system [x 1]*[m c]’ = y Solve (find model parameters m,c ) using Matlab w=Ab
E N D
COMP 116: Introduction to Scientific Programming Lecture 13: So long Matrices
Linear Regression basics • Hypothesize a model • y=mx+c • Set it up as a linear system • [x 1]*[m c]’ = y • Solve (find model parameters m,c) using Matlab • w=A\b • Here w corresponds to the unknowns m,c • This returns the w that minimizes • sum((Aw-b).^2)
Exercise 1: Fit a parabola • Hypothesisy=ax^2+bx+c • Find model parameters a,b,c • Plot x vs ax^2+bx+c • Matlab tip: Use>>hold on Download parabola.mat from lecture page
Exercise II • Download midterm_points.mat from lecture page • Columns correspond to questions and rows to students • Find total points for each student (sum) • Plot histogram of total points (hist) • Find student who got more than 60% and less than 80% (find) • Find the least scoring question. Divide by total points. (min and mean) • Find the questions that had maximum, minimum variance respectively. Plot their histograms. (var)
Advanced exercises: linear programming • How to assign weights to the questions so that the class minimum is maximized? • How to assign weights to the question so that the difference between the class minimum and maximum is maximized?