tmp_sum.m
2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%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