I have been trying to derivate equation under to find the formula for 3 parameters Weibull distribution as same as picture. Can someone please help me fix it?

syms m sigma_i sigma_0 sigma_th i N
lnL = symsum(ln((m/sigma_0) * ((sigma_i - sigma_th) / sigma_0))^(m-1) * exp(-(((sigma_i - sigma_th) / sigma_0) ^m)), i, 1, N);
Df_m = diff(lnL,m)
Df_sigma_0 = diff(lnL,sigma_0)
Df_sigma_th = diff(lnL,sigma_th)

 Réponse acceptée

Is this what you are seeking?
Your equation is too lengthy and contains excessive, unnecessary brackets, as well as mismatched and unclosed brackets.
syms m sigma_i sigma_0 sigma_th i N
%% long equation, too many unnecessary brackets, mismatched brackets, unclosed bracket
% lnL = symsum((m/sigma_0) * ((sigma_i - sigma_th) / sigma_0))^(m-1) * exp(-(((sigma_i - sigma_th) / sigma_0) ^m), i, 1, N);
%% split into two shorter and easy-to-check terms
term1 = ((sigma_i - sigma_th)/sigma_0)^(m-1)
term1 = 
term2 = exp(- ((sigma_i - sigma_th)/sigma_0)^m)
term2 = 
%% function
fcn = (m/sigma_0)*term1*term2
fcn = 
%% sum of function (closed-form expression)
lnL = symsum(fcn, i, 1, N)
lnL = 
%% Derivative of lnL w.r.t. m
Df_m = diff(lnL,m)
Df_m = 
%% Derivative of lnL w.r.t. sigma_0
Df_sigma_0 = diff(lnL,sigma_0)
Df_sigma_0 = 
%% Derivative of lnL w.r.t. sigma_th
Df_sigma_th = diff(lnL,sigma_th)
Df_sigma_th = 

Plus de réponses (1)

This code works, but it will not give you the result you want.
syms m sigma_i sigma_0 sigma_th i N
lnL = symsum(log((m/sigma_0) * ((sigma_i - sigma_th) / sigma_0)^(m-1) * exp(-((sigma_i - sigma_th) / sigma_0)^m)), i, 1, N);
Df_m = diff(lnL,m)
Df_sigma_0 = diff(lnL,sigma_0)
Df_sigma_th = diff(lnL,sigma_th)
The problem is that you need to define sigma_i as an array of length N where N is itself a symbolic variable. This is not possible with the symbolic toolbox. You will need to specify a numerical value for N (usually the number of data points you have).
The below code should work:
syms sigma
syms m sigma_0 sigma_th
N = 15;
sigma = sym('sigma',[1,N]);
lnL = sum(log((m/sigma_0) * ((sigma - sigma_th) / sigma_0).^(m-1) .* exp(-((sigma - sigma_th) / sigma_0).^m)))
Df_m = diff(lnL,m)
Df_sigma_0 = diff(lnL,sigma_0)
Df_sigma_th = diff(lnL,sigma_th)

2 commentaires

Thank you for help me. I have question how can I add ln(x) like in photo?
Thank you for help me. I have question how can I add ln(x) like in photo?
I added it.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Import and Analysis dans Centre d'aide et File Exchange

Produits

Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by