How to optimize the value of x(2)
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Torsten
le 2 Mai 2022
Modifié(e) : Torsten
le 2 Mai 2022
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multiobjective Optimization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!