Solving Normal Equations 3-Parameter Weibull Distribution
1 次查看(过去 30 天)
显示 更早的评论
Hello, I am new to Matlab and would like to know how to input and solve the following Normal equations
1 个评论
Torsten
2022-5-17
What is the function F from which you derived the three equations as dF/dm=0, dF/dc=0 and dF/dg=0 ?
回答(1 个)
Saarthak Gupta
2023-12-28
编辑:Saarthak Gupta
2023-12-28
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);
% 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))
% 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:
- fsolve: https://www.mathworks.com/help/optim/ug/fsolve.html
- Equation Solving Algorithms: https://www.mathworks.com/help/optim/ug/equation-solving-algorithms.html
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!