This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/regression/code/meansquarederrorline.m

16 lines
270 B
Matlab

n = 40;
xmin = 2.2;
xmax = 3.9;
c = 6.0;
noise = 50.0;
% generate data:
x = rand(n, 1) * (xmax-xmin) + xmin;
yest = c * x.^3;
y = yest + noise*randn(n, 1);
% compute mean squared error:
mse = mean((y - yest).^2);
fprintf('the mean squared error is %.0f kg^2\n', mse)