how can I make my optimization stable?

1 view (last 30 days)
Gennaro
Gennaro on 12 Mar 2014
Sometimes output pattersearch gives me inverted values that I expected. How can I set it? here are: first my @my_function and second where it is the estimation function.
function f = AV_function_eps(t, rr, lambda)
%Two different AV node paths (two different refractory periods) with
%vaiable refractory period
%Fixed amplitude (suprathreshold) of atrial impulses, no phase 4
%depolarization
tau1 = t(1);
tau2 = t(2);
tauemax1 = t(3);
tauemax2 = t(4);
alpha = t(5);
tau1_max=tauemax1+tau1;
tau2_max=tauemax2+tau2;
%rr>tau1_max
p1_2=lambda*exp(-lambda*(tau1_max-tau1)/2).*exp(-lambda.*(rr-tau1_max));
%rr>tau2_max
p2_2=lambda*exp(-lambda*(tau2_max-tau2)/2).*exp(-lambda.*(rr-tau2_max));
%tau1<rr<tau1_max
p1_1=lambda*(rr-tau1)./(tau1_max-tau1).*exp(-lambda.*(rr-tau1).^2./(2*(tau1_max-tau1)));
%tau2<rr<tau2_max
p2_1=lambda*(rr-tau2)./(tau2_max-tau2).*exp(-lambda.*(rr-tau2).^2./(2*(tau2_max-tau2)));
%rr<tau1
p1=zeros(size(rr));
%rr<tau2
p2=zeros(size(rr));
x=find(rr>tau1);
p1(x)=p1_1(x);
x2=find(rr>tau1_max);
p1(x2)=p1_2(x2);
x=find(rr>tau2);
p2(x)=p2_1(x);
x2=find(rr>tau2_max);
p2(x2)=p2_2(x2);
% alpha = gamma+.1;
p_rr=alpha*p1+(1-alpha)*p2;
f=-sum(log(p_rr+eps));
function [a, fval, exitflag, OUTPUT] = Estimator(rr, lambda)
Estimation of parameters teta=[t1min t2min tp1 tp2] by jointly maximizing the log-likehood function with respect to teta Algorithm used: PATTERNSEARCH (it is more stable)
t = [ rand(1) rand(1) rand(1) rand(1) rand(1)]; %Initial Guess
options = psoptimset('CompleteSearch', 'on', 'MeshRotate', 'off');
Lb = zeros(1,5);
Ub = ones(1,5);
JPF = @(t) AV_function_eps(t, rr, lambda);
[a, fval, exitflag, OUTPUT] = patternsearch(JPF, t, [], [], [], [], Lb, Ub, options); %a = Optimum parameters

Answers (0)

Community Treasure Hunt

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

Start Hunting!