3 %> @brief Originally created
for Nik
's study [1]
5 %> [1] Purandare, N. C., Patel, I. I., Trevisan, J., Bolger, N., Kelehan, R., von Bünau, G., ... & Martin, F. L. (2013).
6 %> Biospectroscopy insights into the multi-stage process of cervical cancer development: probing for spectral biomarkers
7 %> in cytology to distinguish grades. Analyst.
9 %> @param ds a two-class, 1-feature dataset
11 function threshold = find_distributionthreshold(ds)
15 pieces = data_split_classes(ds);
17 % If first class has greater mean, swaps
18 if mean(pieces(1).X(:, 1)) > mean(pieces(2).X(:, 1))
19 pieces = pieces([2, 1]);
22 X1 = pieces(1).X(:, 1)';
23 X2 = pieces(2).X(:, 1)
';
25 % "class probabilities"
34 xinter = linspace(xmin, xmax, NP);
36 [x1, y1] = distribution(pieces(1).X, NP, [xmin, xmax]);
37 [x2, y2] = distribution(pieces(2).X, NP, [xmin, xmax]);
39 yinter1 = spline(x1, y1, xinter)*p1;
40 yinter2 = spline(x2, y2, xinter)*p2;
44 plot(xinter, yinter1);
46 plot(xinter, yinter2, 'k
');
47 disp('hello from find_distribution threshold
');
50 % Finds top of first mountain to start from there
51 [top1_value, top1_index] = max(yinter1);
55 if yinter1(i) < yinter2(i)
57 % irerror('Mountain with lowest average is completely engulfed!
');
58 irwarning('Mountain with lowest average is completely engulfed!
');
59 threshold = (xmax+xmin)/2;
63 threshold = xinter(i-1);
69 % irerror('Mountain with highest average is completely engulfed!
');
70 irwarning('Mountain with highest average is completely engulfed!
');
71 threshold = (xmax+xmin)/2;