-
Notifications
You must be signed in to change notification settings - Fork 4
/
Eval_rankfilter.m
39 lines (35 loc) · 1.22 KB
/
Eval_rankfilter.m
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
function [FAR,MAR,EDD]=Eval_rankfilter(normal_data, faulty_data, filter_par, x_trip, alm_type)
% pointwise False ALarm Rate (FAR), Missed Alarm Rate (MAR), Expected Detection Delay (EDD)
%
if nargin < 5
alm_type = 'HI';
end
N = filter_par(1); r = filter_par(2);
switch alm_type
case 'HI'
% probability of ALM
p1 = 1-ksdensity(normal_data, x_trip, 'function', 'cdf');
q2 = 1-ksdensity(faulty_data, x_trip, 'function', 'cdf');
% probability of NA
p2 = ksdensity(normal_data, x_trip, 'function', 'cdf');
q1 = ksdensity(faulty_data, x_trip, 'function', 'cdf');
case 'LO'
% probability of ALM
p2 = 1-ksdensity(normal_data, x_trip, 'function', 'cdf');
q1 = 1-ksdensity(faulty_data, x_trip, 'function', 'cdf');
% probability of NA
p1 = ksdensity(normal_data, x_trip, 'function', 'cdf');
q2 = ksdensity(faulty_data, x_trip, 'function', 'cdf');
end
FAR = zeros(size(x_trip));
for i=(N-r+1):N
FAR = FAR + nchoosek(N,i)*p1.^i.*p2.^(N-i);
end
MAR = zeros(size(x_trip));
for i=r:N
MAR = MAR + nchoosek(N,i)*q1.^i.*q2.^(N-i);
end
EDD = zeros(size(x_trip));
for i=1:length(x_trip)
EDD(i) = EDD_rank(p1(i),q1(i),N,r);
end