TracedSample.jl

Make Julia code probabilistic-programming-ready by allowing calls to `sample` to be annotated with traced addresses.
Author probcomp
Popularity
0 Stars
Updated Last
3 Years Ago
Started In
December 2020

TracedSample.jl

Allows for the optional specification of traced addresses (i.e. variable names) in calls to sample and related functions in StatsBase.jl. Providing this information allows ordinary Julia code to be "probabilistic-programming-ready". See also TracedRandom.jl, which provides similar support for random primitives in Random.

julia> sample(:id, 1:5)
3

julia> sample(:fruit, [:apple, :banana, :cherry], weights([0.2, 0.3, 0.5]))
:banana

By default, the addresses (:id and :fruit in the examples above) are ignored, but they can be intercepted via meta-programming (see Genify.jl) to support inference in probabilistic programming systems such as Gen. Addresses can be specified as Symbols, or as pairs from symbols to other types (Pair{Symbol,<:Any}).

Used By Packages

No packages found.