-
Notifications
You must be signed in to change notification settings - Fork 0
/
infer.c
62 lines (47 loc) · 1.14 KB
/
infer.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
/**
@file infer.c
@brief Entrypoint for model inference.
Copyright (c) 2024, Pariksheet Nanda
SPDX-License-Identifier: Apache-2.0
*/
#include <abc.h>
#include <gsl/gsl_randist.h>
/**
Sample from the model using ABC-SMC.
*/
int
main() {
double a_hyperparams[] = {0, 1};
double b_hyperparams[] = {0, 1};
double c[] = {1.50};
double d[] = {0.75};
gsl_ran_function gaussian_tail;
gaussian_tail.func2p = gsl_ran_gaussian_tail;
param_t params[] = {
{"a", &gaussian_tail, a_hyperparams, 2},
{"b", &gaussian_tail, b_hyperparams, 2},
{"c", NULL, c, 0},
{"d", NULL, d, 0},
};
gsl_function model_f;
model_f.function = &lotka_volterra_wrap;
model_f.params = ¶ms;
gsl_function kernel_f;
kernel_f.function = &kde;
gsl_matrix* params_weighted = NULL;
params_weighted = gsl_matrix_alloc(2, 4);
gsl_function sampling;
gsl_function proposal;
int ret = abc_smc(params_weighted,
&model_f,
&kernel_f,
2,
&sampling,
&proposal,
1);
if (ret != GSL_SUCCESS) {
GSL_ERROR("Sample failed", ret);
}
gsl_matrix_free(params_weighted);
return EXIT_SUCCESS;
}