Question & Answer: Write a function to implement regularization based training procedure for 1D regression. The function should have the fol…..

Write a function to implement regularization based training procedure for 1D regression. The function should have the following form: function a = mytrain (train_x, train_y, n, lamda),where train_x is a column vector containing all the input points in the training, train_y is a column vector containing all the output points in the training, n is the order of the polynomial model, lamda is a non-negative regulation parameter, and a is a column vector containing coefficient of the polynomial model.

Write a function to implement testing procedure for 1D regression. The function should have the following form: function test y mytest(test x, a), where test x is a column vector containing all the input points in the test, a is a column vector containing coefficients of the polynomial model, and test y is a column vector containing all the output points in the test.

Write a script to do the following experiment

Create 10 input points for training. They should be evenly distributed between O and 1.

Create 10 corresponding output points for training as follows: cos(2 pi’x)+0.3 randn(10,1)

Create 100 input points for testing. They should be evenly distributed between O and 1

Generate models for lamda-0, and n = 1, 2, 3, 4,5,6,7,8,9, respectively.

Generate models for n = 3, and lamda = 1e-8, 1e-5.1e-2, 1, respectively

Generate models for n = 9, and lamda = 1e-8, 1e-5.1e-2, 1, respectively.

For each model, superimpose the testing results onto cos(2″pix)

Write a report to summarize and discuss your results

Expert Answer

 

ANSWER:

Still stressed from student homework?
Get quality assistance from academic writers!