BlosSOM
Interactive dimensionality reduction on large datasets (EmbedSOM and FLOWER combined)
estimator.cpp
Go to the documentation of this file.
1/* This file is part of BlosSOM.
2 *
3 * Copyright (C) 2021 Sona Molnarova
4 *
5 * BlosSOM is free software: you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free
7 * Software Foundation, either version 3 of the License, or (at your option)
8 * any later version.
9 *
10 * BlosSOM is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * BlosSOM. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#include "estimator.h"
20
21#include <cmath>
22
24{
25 reset();
26}
27
28void
30{
31 a = 0.00001;
32 b = 0.00001;
33 c = 0.00001;
34 d = 0.00001;
35 e = 0.00001;
36 f = 0.00001;
37 alpha = 0.05;
38 coalpha = 1 - alpha;
39}
40
41void
43{
44 // Prevent the division with zero.
45 if (N == 0)
46 N = 100;
47 if (T == 0)
48 T = 0.00001;
49
50 // Computation time of one point.
51 float TN = T / N;
52 // Normalized normal line to the line with slope (-T, T/N).
53 // The normal line before normalization is (T, T/N).
54 float n1 = TN * (1 / (std::sqrt(TN * TN + T * T)));
55 float n2 = T * (1 / (std::sqrt(TN * TN + T * T)));
56 // Distance of the line from origin [0,0].
57 float n3 = T * n1;
58
59 a = a * coalpha + n1 * n1 * alpha;
60 b = b * coalpha + n2 * n2 * alpha;
61 c = c * coalpha + (2 * n1 * n2) * alpha;
62 d = d * coalpha + (-2 * n1 * n3) * alpha;
63 e = e * coalpha + (-2 * n2 * n3) * alpha;
64 f = f * coalpha + n3 * n3 * alpha;
65}
66
67std::tuple<float, float>
69{
70 float x = (c * e - 2 * b * d) / (4 * a * b - c * c);
71 float y = (c * d - 2 * a * e) / (4 * a * b - c * c);
72 return { x, y };
73}
float b
Definition: estimator.h:36
void process_measurement(size_t n, float t)
Definition: estimator.cpp:42
float a
Definition: estimator.h:35
void reset()
Definition: estimator.cpp:29
float e
Definition: estimator.h:39
float f
Definition: estimator.h:40
float coalpha
Definition: estimator.h:42
std::tuple< float, float > get_estimate()
Definition: estimator.cpp:68
float alpha
Definition: estimator.h:41
float c
Definition: estimator.h:37
float d
Definition: estimator.h:38