Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
QUESTION
Matlab Coding Question
- 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 regularization parameter, and a is a column vector containing coefficients 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 0 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 0 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*pi*x)
- Write a report to summarize and discuss your results