You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
465 B
17 lines
465 B
load('./SysID_Exercise_1.mat')
|
|
|
|
w = [x.' ; 2.*x.'.^2-1].';
|
|
|
|
theta_ml = inv(w.' * w) * w.'*(y-0.2);
|
|
|
|
u = [1; 0.4];
|
|
sigma_p = 0.01;
|
|
sigma = 0.1;
|
|
|
|
theta_map = inv(1/sigma * w.' * w + 1/sigma_p*eye(2)) * (1/sigma*w.'*(y-0.2)+u/sigma_p);
|
|
|
|
y_hat_ml = theta_ml(1) * x_v + theta_ml(2) * (2.*x_v.^2-1)+0.2;
|
|
y_hat_map = theta_map(1) * x_v + theta_map(2) * (2.*x_v.^2-1)+0.2;
|
|
|
|
MSE_MLE = sum((y_hat_ml - y_v).^2) / length(y_v)
|
|
MSE_MAP = sum((y_hat_map - y_v).^2) / length(y_v)
|
|
|