How to optimize the value of x(2)
3 ビュー (過去 30 日間)
古いコメントを表示
CODE FOR COMPUTING MEDIAN AND MAXIMUM LIKELIHOOD VALUE. I WANT TO CALCULATE OPTIMUM VALUE OF STANDARD DEVIATION BASED ON INOUT DATA FILE
function likeli
da = load("C:\Users\Admin\OneDrive - IIT Bombay\Desktop\standard deviation\fragility1.txt")%%Damage state in terms of 0 and 1
WH = load("C:\Users\Admin\OneDrive - IIT Bombay\Desktop\standard deviation\velocity1.txt")%%
n = length(da)
xdamage = da(:,1)
x0 = [2]%x valueis a median values%
options = optimset('LargeScale','off','Display','off','TolX',0.001,'TolFun',0.001)
[x,fval] = fminsearch(@myfun,x0,options,n,WH,xdamage)%fval is the likeli hood function%
function f = myfun(x,n,WH,xdamage);
options = optimset('LargeScale','on','Display','off','TolX',0.001,'TolFun',0.001)
p1=0.0;
for i=1:n
x(2) = 0.5;
yx=(log(WH(i)/x(1)))/x(2)%%x(2) is standard deviation
if yx >= 5.0;
y1=5.0;%%maximum value normcdf can take taken as 5%%
elseif yx<=-5.0;
y1=-5.0;
else
y1 = yx;
end
y2=normcdf(y1)
p1=p1+log(((y2)^xdamage(i))*((1.0-y2)^(1.0-xdamage(i))))%%Maximum likeli hood%
end
f=-p1;
return
Hello all I have a querry, I am solving one problem in which I have to compute optimum value of x(2), In this code I have taken x(2) value as constant 0.5. Here da is a file having 0 and 1 (100 values; defined as damage state) and the other WH is file having values between 1.25-2.0 (100 values). Basically this value is computed using some formula 0 means no failure and 1 mean failure.
0 件のコメント
採用された回答
Torsten
2022 年 5 月 2 日
編集済み: Torsten
2022 年 5 月 2 日
da = load("C:\Users\Admin\OneDrive - IIT Bombay\Desktop\standard deviation\fragility1.txt")%%Damage state in terms of 0 and 1
WH = load("C:\Users\Admin\OneDrive - IIT Bombay\Desktop\standard deviation\velocity1.txt")%%
n = length(da);
xdamage = da(:,1);
wh = WH(:,1);
x0 = [2 0.5];%x valueis a median values%
%options = optimset('LargeScale','off','Display','off','TolX',0.001,'TolFun',0.001)
%[x,fval] = fminsearch(@myfun,x0,options,n,wh,xdamage)%fval is the likeli hood function%
[x,fval] = fminsearch(@(x)myfun(x,n,wh,xdamage),x0);%fval is the likeli hood function%
function f = myfun(x,n,wh,xdamage);
p1=0.0;
for i=1:n
yx=(log(wh(i)/x(1)))/x(2);%%x(2) is standard deviation
if yx >= 5.0;
y1=5.0;%%maximum value normcdf can take taken as 5%%
elseif yx<=-5.0;
y1=-5.0;
else
y1 = yx;
end
y2=normcdf(y1);
p1=p1+log(((y2)^xdamage(i))*((1.0-y2)^(1.0-xdamage(i))));%%Maximum likeli hood%
end
f=-p1;
end
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multiobjective Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!