Skip to content

Commit 5df2359

Browse files
authored
Two-step discretization evaluation (TEDIE)
Two-step discretization evaluation (TEDIE) procedure: MATLAB files and example data. m files are written using MATLAB 2016a.
1 parent 9b3ae86 commit 5df2359

File tree

6 files changed

+117
-1
lines changed

6 files changed

+117
-1
lines changed

Diff for: README.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
# DiscretizationAlgorithms
1+
This is the two-step discretization evaluation (TEDIE) procedure. This procedure is proposed by T. Jann, Y. Li, and Dr. P. Vera-Licona.
2+
3+
TEDIE procedure contains two steps:
4+
1. Qualification: run Wilcoxon sign rank test;
5+
2. Evaluaton: calculate mean area between the curves as a criteria;
6+
7+
##------ functions ------##
8+
9+
benchmark.m:
10+
For evaluation step;
11+
Depend on prebenchmark.m;
12+
!! Each time series should come in as a n*1 vertical vector;
13+
This function is able to calculate a matrix with multiple times series when each are coming in a column;
14+
15+
16+
prebenchmark.m:
17+
calculate difference of area between lines formed by 4 points:
18+
line 1: (x1, y1) -- (x2, y2)
19+
line 2: (x3, y3) -- (x4, y4)
20+
A sub-funciton for benchmark.m;
21+
Notice that this is NOT mean area between the curves;
22+
23+
##------ Examples ------##
24+
25+
*.mat:
26+
data file for example use;
27+
28+
main_*.m: example files for TEDIE procedure that uses benchmark.m;
29+

Diff for: TEDIEvignette.docx

208 KB
Binary file not shown.

Diff for: benchmark.m

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function f = benchmark(data1, data2)
2+
m = size(data1,1); % number of rows
3+
n = size(data1, 2); % number of columns
4+
% replace NaN
5+
data1(isnan(data1)) = 0.5 ;
6+
data2(isnan(data2)) = 0.5 ;
7+
% initialization
8+
area = 0;
9+
for i = 1:n
10+
for j = 1:m-1
11+
x1 = j;
12+
x2 = j+1;
13+
x3 = x1;
14+
x4 = x2;
15+
y1 = data1(j,i);
16+
y2 = data1(j+1, i);
17+
y3 = data2(j,i);
18+
y4 = data2(j+1, i);
19+
addarea = prebenchmark(x1,y1,x2,y2,x3,y3,x4,y4);
20+
area = area + addarea;
21+
end
22+
end
23+
f = area/(m*n);

Diff for: example.mat

6.42 KB
Binary file not shown.

Diff for: main_example.m

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
clc,clear
2+
format short
3+
% load an example data file; keep all the files in the same folder;
4+
load('example.mat');
5+
% put the discretization you are interested in here, make sure that your
6+
% loaded data contains the dataset of interest!
7+
test_data = eval( 'meanstd');
8+
% data normalization
9+
nouveau = ( test_data-ones(size(test_data))*min(min(test_data)) )/ (max(max(test_data)) - min(min(test_data)));
10+
clear test_data;
11+
test_data = nouveau;
12+
clear nouveau;
13+
%% qualification
14+
for i = 1:length(original)
15+
res = original(i,:)-test_data(i,:);
16+
rocile(i,1) = signtest(sort(res));
17+
clear res;
18+
end
19+
zygote(1) = quantile(rocile, 0.25);
20+
clear i rocile;
21+
if zygote <0.01
22+
disp('stop here! choose another discretization method!');
23+
else
24+
disp('qualification passed! move to evaluation')
25+
%% evaluation
26+
for i = 1:8
27+
startt = (i-1)*13+1;
28+
endd = i*13;
29+
roche(i,1) = benchmark(original(startt:endd,:)', test_data(startt:endd,:)' );
30+
clear startt endd;
31+
end
32+
zygote(2) = sum(roche)/8;
33+
clear i roche;
34+
disp('mean area between the curve: ')
35+
disp(zygote(2))
36+
end
37+
clear test_data;

Diff for: prebenchmark.m

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function f = prebenchmark(x1,y1,x2,y2,x3,y3,x4,y4)
2+
%% this is written by Yuezhe Li at Oct. 16, 2016
3+
% this is a benchmark dirretization eavluation proposed by Tiffiny Jann as a REU student
4+
% this is intend to calculate area between two lines
5+
% line1 = (x1, y1) -- (x2,y2)
6+
% line2 = (x3, y3) -- (x4, y4)
7+
diff1 = y3-y1;
8+
diff2 = y4-y2;
9+
dif = diff1*diff2;
10+
if dif < 0
11+
% here 2 line intersects somewhere in the middle
12+
m1 = (y2-y1)/(x2-x1);
13+
b1 = y1 - m1*x1;
14+
m2 = (y4-y3)/(x4-x3);
15+
b2 = y3 - m2*x3;
16+
xint = (-1)*(b2 - b1)/(m2-m1);
17+
area1 = (y3-y1)*abs(xint-x1)/2;
18+
area2 = abs(y4-y2)*abs(xint-x2)/2;
19+
area = area1 + area2;
20+
else if dif > 0
21+
area = ( abs(diff1) + abs(diff2) ) * abs(x2-x1)/2;
22+
else
23+
ydif = max( abs(y4-y2), abs(y3-y1) );
24+
xdif = abs(x2 - x1);
25+
area = xdif*ydif/2;
26+
end
27+
end
28+
f = area;

0 commit comments

Comments
 (0)