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 Symbol
s, or as pairs from symbols
to other types (Pair{Symbol,<:Any}
).