gen_rs/
lib.rs

1//! `gen_rs` is a a library for general-purpose, low-level probabilistic modeling and inference.
2//! Modeling and inference are separated by a trait interface, called `GenFn`.
3//! 
4//! Any function that implements `GenFn` (representing a Bayesian model) can use and compose
5//! any inference procedure in the standard inference library.
6
7#![deny(missing_docs)]
8#![allow(non_upper_case_globals)]
9
10extern crate approx;
11extern crate nalgebra;
12extern crate rand;
13extern crate regex;
14
15
16use std::cell::RefCell;
17use rand::rngs::ThreadRng;
18
19
20thread_local!(
21    /// Forked PRNG, accessible as a static crate-level thread-local constant. (Use like `GLOBAL_RNG.with_borrow_mut(|rng| { ... })`).
22    pub static GLOBAL_RNG: RefCell<ThreadRng> = RefCell::new(ThreadRng::default())
23);
24
25
26/// Definition of the Generative Function Interface (GFI).
27pub mod gfi;
28
29/// Utilities for parsing addresses (special keys used in the `Trie` data structure).
30pub mod address;
31
32/// Implementations of the `Trie` data structure, used extensively in `modeling::triefn`. 
33pub mod trie;
34
35/// Distributions and a modeling DSL built on `Trie`s.
36pub mod modeling;
37
38/// Standard inference library.
39pub mod inference;
40
41mod mathutils;
42
43// modeling libs
44pub use trie::Trie;
45pub use address::{SplitAddr, normalize_addr};
46pub use gfi::{Trace, GenFn, GfDiff};
47pub use modeling::dists::{u01,Distribution,bernoulli,uniform_continuous,uniform,uniform_discrete,categorical,normal,mvnormal};
48pub use modeling::triefn::{TrieFn,TrieFnState,AddrTrie};
49pub use modeling::unfold::Unfold;
50pub use mathutils::logsumexp;
51
52// inference libs
53pub use inference::importance_sampling;
54pub use inference::metropolis_hastings;
55pub use inference::mh;
56pub use inference::ParticleSystem;