[regression] smaller steps for derivative

This commit is contained in:
2020-12-20 13:15:40 +01:00
parent dea6319e75
commit 17bf940101
6 changed files with 21 additions and 22 deletions

View File

@@ -30,7 +30,7 @@ end
function gradmse = meanSquaredGradient(x, y, func, p)
gradmse = zeros(size(p, 1), size(p, 2));
h = 1e-5; % stepsize for derivatives
h = 1e-7; % stepsize for derivatives
mse = meanSquaredError(x, y, func, p);
for i = 1:length(p) % for each coordinate ...
pi = p;

View File

@@ -7,7 +7,7 @@ function dmsedc = meanSquaredGradientCubic(x, y, c)
%
% Returns: the derivative of the mean squared error at c.
h = 1e-5; % stepsize for derivatives
h = 1e-7; % stepsize for derivatives
mse = meanSquaredErrorCubic(x, y, c);
mseh = meanSquaredErrorCubic(x, y, c+h);
dmsedc = (mseh - mse)/h;

View File

@@ -1,3 +1,5 @@
meansquarederrorline; % generate data
cs = 2.0:0.1:8.0;
mseg = zeros(length(cs));
for i = 1:length(cs)

View File

@@ -1,8 +1,8 @@
meansquarederrorline; % generate data
c0 = 2.0;
eps = 0.0001;
thresh = 0.1;
eps = 0.00001;
thresh = 1.0;
[cest, cs, mses] = gradientDescentCubic(x, y, c0, eps, thresh);
subplot(2, 2, 1); % top left panel

View File

@@ -2,7 +2,7 @@ meansquarederrorline; % generate data
p0 = [2.0, 1.0];
eps = 0.00001;
thresh = 50.0;
thresh = 1.0;
[pest, ps, mses] = gradientDescent(x, y, @powerLaw, p0, eps, thresh);
pest
@@ -28,5 +28,3 @@ plot(x, y, 'o'); % plot original data
xlabel('Size [m]');
ylabel('Weight [kg]');
legend('fit', 'data', 'location', 'northwest');
pause