function dmsedc = meanSquaredGradientCubic(x, y, c) % The gradient of the mean squared error for a cubic relation. % % Arguments: x, vector of the x-data values % y, vector of the corresponding y-data values % c, the factor for the cubic relation. % % Returns: the derivative of the mean squared error at c. h = 1e-7; % stepsize for derivatives mse = meanSquaredErrorCubic(x, y, c); mseh = meanSquaredErrorCubic(x, y, c+h); dmsedc = (mseh - mse)/h; end