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?

4 ビュー (過去 30 日間)
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)

採用された回答

Sam Chak
Sam Chak 2025 年 3 月 13 日
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 = 

その他の回答 (1 件)

Torsten
Torsten 2025 年 3 月 13 日
編集済み: Torsten 2025 年 3 月 13 日
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 件のコメント
Trong Nhan Tran
Trong Nhan Tran 2025 年 3 月 13 日
Thank you for help me. I have question how can I add ln(x) like in photo?
Torsten
Torsten 2025 年 3 月 13 日
Thank you for help me. I have question how can I add ln(x) like in photo?
I added it.

サインインしてコメントする。

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by