Question
Do in Javascript. Complete the function calc_nonlinLSQ_gaussnewton(): Use Gauss-Newton non-linear least squares to estimate the parameters for the function from (3). Use the following for
Do in Javascript.
Complete the function calc_nonlinLSQ_gaussnewton(): Use Gauss-Newton non-linear least squares to estimate the parameters for the function from (3).
Use the following for your initial guess: a=0.5, b=2, c=0.5, d=0.5 Stop after 10 iterations. (Note, these are the default values in the template.)
As with problems 1-2, find the sum of squared error and create a plot. (Calculate the sum of squared error after each iteration.) Do you think this model fits the data better than previous ones? Why or why not? (5 pts)
//Peform Gauss-Newton non-linear least squares on polynomial a*x^b+c*x+d //initial_p: contains initial guess for parameter values //max_iterations: number of iterations to perform before stopping //return final parameter array p, where p[0]=d,...,p[3]=a function calc_nonlinLSQ_gaussnewton(data,initial_p,max_iterations) { let N=numeric.dim(data)[0]; 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
let p=initial_p.slice(0); //Make a copy, just to be safe let dy=numeric.rep([N],0); for(let iter=0;iter<=max_iterations;++iter) { //Step 1: Find error for current guess for(let i=0;i There are 3 Steps involved in it See step-by-step solutions with expert insights and AI powered tools for academic successStep by Step Solution
Step: 1
Get Instant Access to Expert-Tailored Solutions
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