r-gen
A generative programming framework for the rust programming language. This is heavily based on the Gen library for the Julia programming language.
Example using importance resampling 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. 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.