-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinference.mli
70 lines (55 loc) · 2.64 KB
/
inference.mli
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
70
(* The library to support a probabilistic embedded domain specific language *)
(* Probabilistic inference procedures *)
(* These procedures implement different exploration strategies over a
lazy search tree, transforming a search tree into a flatter form *)
open Ptypes
(* Explore and flatten the tree:
perform exact inference to the given depth *)
val explore :
int option -> (* max depth; if None, no limit *)
'a pV -> (* Input lazy search tree *)
'a pV (* Output lazy search tree *)
(* Partially explore but do not flatten the tree: *)
(* Pre-computing choices as an optimization*)
val shallow_explore :
int -> (* max depth *)
'a pV -> (* Input lazy search tree *)
'a pV (* Output lazy search tree *)
(* Explore the tree till we find the first success --
the first leaf (V v) -- and return the resulting
tree. Return the empty tree otherwise. *)
val first_success:
'a pV -> 'a pV
(* Compute the bounds on the probability of *)
(* evidence *)
val bounded_explore :
int -> (* max size of the queue *)
unit pV -> (* Input lazy search tree *)
prob * prob (* Probability bounds *)
(* Given a sampler, a function 'seed->'seed,
run it a certain number of times and return the
resulting seed and the number of runs *)
type sample_runner =
{sample_runner : 'seed. 'seed -> ('seed -> 'seed) -> 'seed * int}
(* Approximate inference: sampling *)
val rejection_sample_dist :
'a vc selector -> (* selector among the branches *)
int -> (* Number of iterations *)
'a pV -> (* Input lazy search tree *)
'a pV (* Output lazy search tree *)
val sample_dist : (* Explore with look-ahead sampling *)
'a pV selector -> (* selector among the branches *)
sample_runner -> (* Do a few samples *)
'a pV -> (* Input lazy search tree *)
'a pV (* Output lazy search tree *)
(* Useful utility functions *)
(* Compute the statistics of sampling, over various seeds *)
val statistics :
int * int -> (* The range of random seed values *)
(int -> 'a pV) -> (* Sampling procedure, takes seed *)
('a * float * float) list (* Value, mean, standard deviation *)
val timeit : (unit -> 'a) -> 'a (* Time the execution *)
val normalize : (* Normalize the distribution *)
'a cdist -> (* Input distribution *)
prob * (* Normalization constant, total prob *)
'a dist (* Normalized distribution *)