r-gen
A probabilistic programming framework for the rust programming language. This is heavily based on the Gen library for the Julia programming language.
Example using importance sampling to estimate latent variables.
...
Outputs:
Actual value for p: 0.8011431168181488
Generated value for p: 0.7879998086169554
Note the #[r_gen]
tag on the generative function. This must be on any of your generative functions in order to use simulate
and generate
on them. One other stipulation of a generative function is that it must have a single argument. This can be a tuple or ()
if you dont need to pass any arguments. In order to make a random choice (sample from a distribution) you must use the sample!()
macro. The syntax for this is
sample!;
This samples the Distribution
given and stores the result in identifier
. Distribution
is defined as
Value
is defined as
The variant of the enum that is returned from sampling depends on the distribution being sampled.
This framework is in EARLY stages of development. Everything is subject to change.