# Solving Normal Equations 3-Parameter Weibull Distribution

5 views (last 30 days)

Show older comments

##### 1 Comment

Torsten
on 17 May 2022

What is the function F from which you derived the three equations as dF/dm=0, dF/dc=0 and dF/dg=0 ?

### Answers (1)

Saarthak Gupta
on 28 Dec 2023

Edited: Saarthak Gupta
on 28 Dec 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);

% 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 Comments

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!