-
Notifications
You must be signed in to change notification settings - Fork 1
/
facebook-api.txt
52 lines (40 loc) · 1.95 KB
/
facebook-api.txt
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
// a representation of probability that supports either symbolic or concrete
// values
struct probability;
// a conditional probability table
struct cpt;
struct bayesian_network;
struct compiled_bayesian_network;
// specifies how many values each variable in the bayesian network can take
// shape[0] gives the # of values for var 0
typedef unsigned int* shape;
// create a Bayesian network data structure
bayesian_network* make_bayesian_network(unsigned int num_vars,
shape s,
cpt * cpts, // list of conditional probability tables
);
// create a CPT
// probabilities[i] gives the conditional probability at index i
//
// For example: if vars = [0, 1] and shape = [3,2], meaning there are two variables in
// this CPT (vars 0 and 1) and var 0 has 3 values and var 1 has 2 values, then
// i=0 is state (var 0 = 0, var 1 = 0)
// i=1 is state (var 0 = 0, var 1 = 1)
// i=2 is state (var 0 = 1, var 1 = 0)
// ...
cpt* make_cpt(shape s, unsigned int* vars, unsigned int num_vars, probability* probabilities)
// a struct that maps symbol probabilities to concrete probabilities
struct symbol_table;
// generate an empty symbol table
symbol_table* make_symbol_table();
// sets a probability in the symbol table
void set_probability(symbol_table* st, unsigned int idx, double probability);
// make a symbol probability that will be substituted later during inference
// the ID uniquely identifies this probability
probability* make_symbolic_prob(unsigned int id);
// make a concrete probability
probability* make_concrete_prob(double val);
// compile bayesian network for amortized inference
compiled_bayesian_network* compile_bayesian_network(unsigned int num_vars, cpt * cpts, unsigned int num_cpt);
// Computes the joint marginal for the subset of variables `query_vars`
double** marginal(compiled_bayesian_network* bn, symbol_table* st, unsigned_int* query_vars, unsigned_int num_vars);