forked from rgbdemo/nestk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-math.cpp
67 lines (57 loc) · 1.59 KB
/
test-math.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <ntk/utils/debug.h>
#include <ntk/numeric/utils.h>
#include <ntk/stats/distributions.h>
#include <ntk/stats/hypothesis_testing.h>
#include <ntk/utils/xml_serializable.h>
// #include <gsl/gsl_cdf.h>
using namespace ntk;
#if 0
void test_distribution()
{
EmpiricalDistribution d;
for (int i = 0; i < 1; ++i) d.addValue(10);
for (int i = 0; i < 5; ++i) d.addValue(20);
for (int i = 0; i < 5; ++i) d.addValue(50);
for (int i = 0; i < 3; ++i) d.addValue(70);
for (int i = 0; i < 1; ++i) d.addValue(80);
XMLNode e;
d.fillXmlElement(e);
EmpiricalDistribution d2;
d2.loadFromXmlElement(e);
ntk_dbg_print(d.cdf(-10), 0);
ntk_dbg_print(d.cdf(0), 0);
ntk_dbg_print(d.cdf(10), 0);
ntk_dbg_print(d.cdf(15), 0);
ntk_dbg_print(d.cdf(35), 0);
ntk_dbg_print(d.cdf(90), 0);
ntk_dbg_print(d.cdf(100), 0);
ntk_dbg_print(d.cdf(200), 0);
ntk_dbg_print(d2.cdf(-10), 0);
ntk_dbg_print(d2.cdf(0), 0);
ntk_dbg_print(d2.cdf(10), 0);
ntk_dbg_print(d2.cdf(15), 0);
ntk_dbg_print(d2.cdf(35), 0);
ntk_dbg_print(d2.cdf(90), 0);
ntk_dbg_print(d2.cdf(100), 0);
ntk_dbg_print(d2.cdf(200), 0);
}
#endif
void test_abs_difference_distribution()
{
std::vector<double> d1 (4);
std::vector<double> d2 (4);
std::vector<double> output;
d1[0] = 0.2; d1[1] = 0.1; d1[2] = 0.3; d1[3] = 0.4;
d2[0] = 0.4; d2[1] = 0.1; d2[2] = 0.2; d2[3] = 0.3;
estimate_abs_difference_distribution(output, d1, d2);
for (int i = 0; i < (int)output.size(); ++i)
{
ntk_dbg(1) << i << ": " << output[i];
}
}
int main()
{
ntk::ntk_debug_level = 1;
test_abs_difference_distribution();
return 0;
}