What is Newton's method when there is a lot of input?

1 view (last 30 days)
I am trying to estimate 3parameters of mixed weibull distribution. And I think the Nweton method for it.
But, error happend
'Error: exit :There are too many output arguments.
Error: etimation_weibull> accelerated_newton (line 30)
if ~ exit ('n_iter','var')
Error: etimation_weibull (line 21)
[x, x_err, x_h] = accelerated_newton (func, dfunc, x0, conv_tol, n_iter);
I think that the error is related to the part where the @ function is used. Is it not possible if there are multiple inputs?
Also, is there any other method for estimating the three parameters of the mixed Weibull distribution?
%% Estimation 3parameters in weibull distribution
load('weibul.mat')
Error using load
Unable to find file or directory 'traj.mat'.
X = Euclidean_distance; % input data
%% Define first-order and second-order derivatives of Weibull distribution
a = 0.1;
b = 0.1;
c = 0.1;
func = @(x,a,b,c) 1-exp((x-c)/a).^b;
dfunc = @(x,a,b,c) (x>c).*(b/a).*(((x-c)/a).^(b-1)).*exp(-(x-c)/a).^b;
x0 = Euclidean_distance(1);
conv_tol = 1e-10;
n_iter = 30;
[x, x_err, x_h] = accelerated_newton(func,dfunc,x0,conv_tol,n_iter); %● error happend
%% newton-methods function
function [x, x_err, x_h] = accelerated_newton(func,dfunc,x0,conv_tol,n_iter)
if ~isa(func, 'function_handle') || ~isa(dfunc,'function_handle')
error('function must be a handle (add"@" before the function name')
end
if ~exit('n_iter', 'var')
n_iter = 30;
end
if ~exist('conv_tol', 'var')
conv_tol = 1e-15;
end
x = x0;
x_h = nan(n_iter + 1, 1);
x_h(1) = x;
for k=1:n_iter
f = func(x);
df = dfunc(x);
delta = f./df;
if k==1
df_23 = dfunc(x - 2.*delta./3);
FF = 0.5 + sqrt(max(0 ,0.75.*df_23 - 0.5));
else
d2f = (4.*df + 2.*df_old - 6.*(f - f_old)./(x - x_old))./(x-x_old);
A2_hat = -.5.*d2f./df;
FF = 0.5 + sqrt(max(0, 0.25 - A2_hat.*delta));
end
x_old = x;
x = x_old - delta./FF;
x_h(k+1) = x;
x_err = abs(x_old - x);
if ((x_err < conv_tol) && (abs(f) - conv_tol))
x_h(k+2:n_iter+1) = [];
break;
end
df_old = df;
f_old = f;
if k == n_iter
disp('The function did not converge')
end
end
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by