Public API
ARS.ARSampler
— MethodARSampler(
obj::ARS.Objective{F<:Function, G<:Function},
initial_points::Array{T<:AbstractFloat, 1},
domain::Tuple{T<:AbstractFloat, T<:AbstractFloat}
) -> ARS.ARSampler{T, F, G} where {T<:AbstractFloat, F<:Function, G<:Function}
Initialize an adaptive rejection sampler over a (log) objective function from obj
. initial_points
should be a vector of abscissae defining the initial segments of the sampler. At least 2 of the points should be on opposite sides of the objective function's maximum.
ARSampler(obj, initial_points, domain)
defined at /home/runner/work/ARS.jl/ARS.jl/src/ARS.jl:321
.
ARS.Objective
— TypeObjective(f)
Objective(f, adbackend)
Objective(f, adbackend, init)
Create an Objective
for a function automatically generating its gradient. Gradients are calculated using DifferentiationInterface.jl
using the backend of choice with Mooncake.jl
being the default. In order to prepare the gradient an initial value is required. By default this is one(Float64)
. If a gradient for a different type is desired, it should be specified.
Observe that f
should be in its log-concave form and that no checks are performed in order to verify this.
Example
# Create a sampler using `Mooncake.jl` autodiff and Float32 as its eltype
ARS.Objective(somefun, AutoMooncake(; config=nothing), one(Float32))
# Create a sampler using `AutoDiff.jl` autodiff and the default Float64 as its eltype
ARS.Objective(somefun, AutoForwardDiff())
ARS.Objective
— MethodARS.sample!
— Functionsample!([rng=default_rng()], s::ARSampler, n::Integer, add_segments::Bool=true)
sample!([rng=default_rng()], v::AbstractVector, s::ARSampler, add_segments::Bool=true)
Draw samples from s
. If supplied, a vector v
will be filled with samples. Otherwise the number of samples is specified with n
.