Solving Normal Equations 3-Parameter Weibull Distribution

4 visualizaciones (últimos 30 días)
Danny Guana
Danny Guana el 17 de Mayo de 2022
Editada: Saarthak Gupta el 28 de Dic. de 2023
Hello, I am new to Matlab and would like to know how to input and solve the following Normal equations
  1 comentario
Torsten
Torsten el 17 de Mayo de 2022
What is the function F from which you derived the three equations as dF/dm=0, dF/dc=0 and dF/dg=0 ?

Iniciar sesión para comentar.

Respuestas (1)

Saarthak Gupta
Saarthak Gupta el 28 de Dic. de 2023
Editada: Saarthak Gupta el 28 de Dic. de 2023
Hi Danny,
Looks like you are trying to solve a system of nonlinear equations in the variables “m”, “c”, “g”.
This qualifies as a typical root-finding problem. MATLAB offers the “fsolve” function as part of the Optimization Toolbox for this purpose.
Refer to the following code:
% Define x and w vectors, to be used in paramfunc
x = randi(10,10,1);
w = randi(10,10,1);
% Parameterize paramfunc using anonymous function since the problem is defined in terms of p, and
% not x and w
fun = @(p)paramfunc(p,x,w);
p0 = [1,-0.0001,-10];
options = optimoptions('fsolve','Display','iter');
[p,fval] = fsolve(fun,p0,options);
Norm of First-order Trust-region Iteration Func-count ||f(x)||^2 step optimality radius 0 4 19177.1 1.13e+04 1 1 8 2664.67 1 4.21e+03 1 2 12 20.189 1.84879 338 2.5 3 13 20.189 4.62196 338 4.62 4 17 0.996424 1.15549 51.6 1.16 5 18 0.996424 2.88873 51.6 2.89 6 22 0.559938 0.722182 18.2 0.722 7 26 0.548133 0.722182 18.2 0.722 8 30 0.526196 0.722182 19.8 0.722 9 34 0.477128 0.722182 21.7 0.722 10 38 0.396303 0.722182 23.8 0.722 11 42 0.306712 0.722182 26 0.722 12 46 0.0997196 0.525304 15.5 0.722 13 50 1.61082e-05 0.0711707 0.183 0.722 14 54 8.89285e-11 0.00299213 0.000458 0.722 15 58 2.67257e-22 3.94812e-06 7.88e-10 0.722 Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
% To verify if the solution is reliable, calculate the residual (sum of squares of fval) to see how close it is to zero.
% A small residual confirms that p is a solution.
sum(sum(fval.*fval))
ans = 2.6726e-22
% System of nonlinear equations to solve
function F = paramfunc(p,x,w)
m = p(1);
c = p(2);
g = p(3);
F = [sum(m.*log(x-g).^2 + log(x-g).*(c-w))
sum(c-w+m.*log(x-g))
sum((log(exp(1))./(x-g)).*(w-m.*log(x-g))-c)];
end
“fsolve” uses Levenberg-Marquardt and trust-region algorithms to find roots of the system of equations. Use one of these methods if the system may not have a zero. The algorithm still returns a point where the residual is small.
By default, “fsolve” chooses the trust-region dogleg algorithm, and its success in finding a solution will depend on the values in x, w, and the initial guess p0.
Refer to the following MATLAB documentation for further reference:

Categorías

Más información sobre Systems of Nonlinear Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by