IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
blmisc_rowsout_kernel.m
Go to the documentation of this file.
1 %> @brief Outlier removal by Kernel distribution estimation
2 %> @sa uip_blmisc_rowsout_kernel.m
4  properties
5  %> Kernel width as a percentage of the bin width
6  kernelwidth = .1;
7  end;
8 
9  properties(SetAccess=protected)
10  distr_x;
11  distr_y;
12  end;
13 
14  methods
15  function o = blmisc_rowsout_kernel(o)
16  o.classtitle = 'Kernel';
17  end;
18  end;
19 
20  methods
21  function o = calculate_ranges(o, data)
22  o.ranges = [];
23  o = o.calculate_distances(data);
24  F = 50;
25  wid = (max(o.distances)-min(o.distances))/o.no_bins*o.kernelwidth;
26  [xa, ya] = distribution(o.distances, o.no_bins*F, [], wid);
27  ya = ya/sum(ya)*numel(o.distances)*F;
28  o.distr_x = xa;
29  o.distr_y = ya;
30  z = o.get_distrboolmap(ya);
31 
32  % Needs edges
33  deltax = mean(diff(xa));
34  edges = [xa-deltax/2, xa(end)+deltax/2];
35 % edges = [xa xa(end)+deltax];
36 
37  flag_in = 0; % Inside a discarded range
38  for i = 1:length(z)+1
39  if flag_in && (i == length(z)+1 || z(i))
40  o.ranges(end+1, :) = [edges(ia), edges(i)];
41  flag_in = 0;
42  elseif ~flag_in && i <= length(z) && ~z(i)
43  ia = i;
44  flag_in = 1;
45  end;
46  end;
47  end;
48 
49  function o = draw_histogram(o)
50  o = draw_histogram@blmisc_rowsout_uni(o);
51  plot(o.distr_x, o.distr_y, 'Color', [151, 0, 112]/255, 'LineWidth', 3);
52  hold on;
53  o.draw_thresholds();
54  end;
55  end;
56 end
57 
Distribution-Based Outlier Removal.
function distribution(in x, in no_points, in range, in wid)
Univariate Outlier removal.
Analysis Session (AS) base class.
Definition: as.m:6
Outlier removal by Kernel distribution estimation.