Commit 7aced9a4 by Chiara Antonini

Upload new file

1 parent 17f12dfd
%Class that extends the abstract class TailMethod. The method compute_tail
%computes the upper and lower tail of a pdf by selecting the upper and lower quartile.
%It takes in input an object TimeBehavior containing the values of the evaluation function,
%the array perturbation of perturbed parameters and tail_size which specifies
%the number of samples in each tail. It returns in output the following variables:
% - XiMin is the array containing parameter samples in the lower tail
% - XiMax is the array containing parameter samples in the upper tail
classdef tmp_sum < TailMethod
properties
step_thr
end
methods
function obj=tmp_sum(step)
obj.step_thr=step;
end
function [XiMax,XiMin]=compute_tailspdf(obj,obj_TimeBehavior,perturbation,tail_size)
% estimation of the pdf of the evaluation function
pdf_obj=pdfEstimator();
samples=obj_TimeBehavior.evalFuncValues;
BinEdges=[min(samples):(max(samples)-min(samples))/length(samples):max(samples)];
[ks_y,xbin]=pdf_obj.evaluate_pdf(obj_TimeBehavior.evalFuncValues,BinEdges);
[low_index, high_index]=obj.compute_thr(xbin,ks_y,obj_TimeBehavior.evalFuncValues,tail_size);
XiMin=[];
XiMax=[];
for j=1:size(obj_TimeBehavior.evalFuncValues,1)
if high_index(j,1)==1
XiMax=[XiMax;perturbation(j,:)];
end
if low_index(j,1)==1
XiMin=[XiMin;perturbation(j,:)];
end
end
end
%The method compute_thr calculates the upper and lower quartile of a pdf
function [low_index,high_index]=compute_thr(obj,BinEdges,ks_y,Results,tail_size)
low_thr=0;
high_thr=1;
while(low_thr < high_thr)
tmp_sum=0;
center_pdf=[];
for h=1:length(ks_y)
tmp_sum=tmp_sum+(BinEdges(2)-BinEdges(1))*ks_y(h);
if(tmp_sum>=low_thr && tmp_sum<=high_thr)
center_pdf=[center_pdf, BinEdges(h)];
end
end
low_index=Results<=center_pdf(1);
low_tail=Results(low_index);
high_index=Results>=center_pdf(end);
high_tail=Results(high_index);
if(length(low_tail)<tail_size)
low_thr=low_thr+obj.step_thr;
end
if(length(high_tail)<tail_size)
high_thr=high_thr-obj.step_thr;
end
if(length(low_tail)>=tail_size && length(high_tail)>=tail_size)
disp(['THE LOW THRESHOLD IS ',num2str(low_thr)])
disp(['THE HIGH THRESHOLD IS ',num2str(high_thr)])
break
end
if(low_thr>=high_thr)
disp('It is not possible to find the low and high thresholds')
end
end
end
end
end
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!