-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_specific.c
69 lines (57 loc) · 2.21 KB
/
test_specific.c
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
68
69
#include "hope.h"
#include "liknorm.h"
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void test_old_one(void);
static void test_marc(void);
int main()
{
test_old_one();
test_marc();
return hope_status();
}
static void test_old_one(void)
{
struct LikNormMachine *machine = liknorm_create_machine(500);
double log_zeroth, mean, variance;
double n = 142100;
double k = 78155;
liknorm_set_binomial(machine, k, n);
liknorm_set_prior(machine, 1.108785906137200072407722473145,
8.231554676556697813794016838074);
liknorm_integrate(machine, &log_zeroth, &mean, &variance);
CLOSE(log_zeroth, -40.26009679144215169799);
CLOSE(mean, 0.20089983974431713243);
CLOSE2(variance, 0.00002843348172375942, 1e-07, 0);
liknorm_destroy_machine(machine);
}
static void test_marc(void)
{
struct LikNormMachine *machine = liknorm_create_machine(500);
double log_zeroth, mean, variance;
liknorm_set_bernoulli(machine, 0.5);
double eta[] = {8.68315118780285e+19 * (0 / 100000.0),
8.68315118780285e+19 * (1 / 100000.0),
8.68315118780285e+19 * (337 / 100000.0),
8.68315118780285e+19 * (338 / 100000.0),
8.68315118780285e+19};
double desired_log0[] = {-0.6969067887453335163883139102836139500141,
-13194139533312., 0., 0., 0.};
double desired_mean[] = {0.0000000000000000989284694679729687520675,
26312579615912.1718750, 8867339309450631.000,
8893651729117382.00, 2631257911700760576.00};
double desired_variance[] = {0.0300768633943054898571833888354376540519,
DBL_EPSILON, DBL_EPSILON, DBL_EPSILON,
DBL_EPSILON};
for (unsigned i = 0; i < sizeof(desired_log0) / sizeof(double); ++i)
{
liknorm_set_prior(machine, 33.0, eta[i]);
liknorm_integrate(machine, &log_zeroth, &mean, &variance);
CLOSE(log_zeroth, desired_log0[i]);
CLOSE2(mean, desired_mean[i], 1e-09, 1e-09);
CLOSE(variance, desired_variance[i]);
}
liknorm_destroy_machine(machine);
}