Question
Do in Javascript. Complete the function calc_linLSQ_line(): Use linear least squares to estimate the parameters (a and b) for the following model: (, , )
Do in Javascript.
Complete the function calc_linLSQ_line(): Use linear least squares to estimate the parameters (a and b) for the following model: (, , ) = +
Also, calculate the sum of squared error and include in your report a plot using the parameter values you found. (4 pts)
function calc_linLSQ_line(data) { let N=numeric.dim(data)[0]; //Number of data points let x=squeeze_to_vector(numeric.getBlock(data,[0, 0],[N-1, 0])); //Extract x (dependent) values let y=squeeze_to_vector(numeric.getBlock(data,[0, 1],[N-1, 1])); //Extract y (target) values //Note: x and y are both vectors, use them accordingly. //(For this homework x is a vector, but generally speaking it may not be!)
//Setup matrices/vectors for calculation let A=numeric.rep([N,2],0); //Make an empty (all zero) Nx2 matrix let b=numeric.rep([N],0); //Make an empty N element vector for(let i=0;i A[i][0]=??; A[i][1]=??; b[i]=??; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started