API Documentation

This is the stable public API of BAT. Forward/backward compatibility follows Julia's semantic versioning rules.

Types

Functions and macros

Documentation

BAT.bat_bgmlFunction
bat_bgml(
    likelihood, prior,
    [algorithm::BAT.MaxDensityAlgorithm],
    [context::BATContext]
)

Estimate the maximum (log-)likelihood parameter point using Bayesian-Guided Maximum Likelihood (BGML).

BGML runs the optimization algorithm in the transformed space where the transformation is derived from prior and algorithm. Typically it is the space in which prior becomes a standard multivariate normal (or other standard) distribution. The optimization target is purely logdensityof(likelihood). The given prior only informs the choice of parameter space. As a likelihood is invariant under reparameterization, the result is not biased by the choice of prior, provided that prior does not vanish in valid parameter regions of non-negligible likelihood and that the optimizer finds the global maximum of the likelihood within the search space. The numerical result may still depend on prior through the parameterization of the search space and the starting values.

Returns a NamedTuple of the shape

(result = v, ...)
Note

Do not add methods to bat_bgml, add methods to bat_bgml_impl instead.

source
BAT.bat_convergenceFunction
bat_convergence(
    algoutput,
    [algorithm::ConvergenceTest],
    [context::BATContext]
)

Check if an algorithm has converged, based on it's output algoutput

Returns a NamedTuple of the shape

(result, ...)

result indicates whether algoutput and must either be a Bool or support convert(Bool, result). It should typically contains measures of algorithm convergence, like a convergence value and it's threshold, etc.

Result properties not listed here are algorithm-specific and are not part of the stable public API.

Note

Do not add add methods to bat_convergence, add methods to bat_convergence_impl instead.

source
BAT.bat_defaultFunction
bat_default(f::Base.Callable, argname::Symbol, objectives...)
bat_default(f::Base.Callable, argname::Val, objectives...)

Get the default value for argument argname of function f to use for objective(s).

objective(s) are mandatory arguments of function f that semantically constitute it's main objective(s), and that that a good default choice of optional arguments (e.g. choice of algorithm(s), etc.) may depend on. Which arguments are considered to be objectives is function-specific.

For example:

bat_default(bat_sample, :algorithm, density::PosteriorMeasure) == RandomWalk()
bat_default(bat_sample, Val(:algorithm), samples::DensitySampleVector) == SystematicResampling()
source
BAT.bat_eff_sample_sizeFunction
bat_eff_sample_size(
    v::Union{AbstractVector{<:Real},AbstractVectorOfSimilarVectors{<:Real}},
    [algorithm::EffSampleSizeAlgorithm],
    [context::BATContext]
)

bat_eff_sample_size(
    smpls::DensitySampleVector,
    [algorithm::EffSampleSizeAlgorithm],
    [context::BATContext]
)

Estimate effective sample size estimation for variate series v, resp. density samples smpls, separately for each degree of freedom.

Returns a NamedTuple of the shape

(result = eff_sample_size, ...)

Result properties not listed here are algorithm-specific and are not part of the stable public API.

Note

Do not add add methods to bat_eff_sample_size, add methods to bat_eff_sample_size_impl instead.

source
BAT.bat_findmedianFunction
bat_findmedian(
    samples::DensitySampleVector
)

The function computes the median of marginalized samples.

Returns a NamedTuple of the shape

(result = v, ...)

Result properties not listed here are algorithm-specific and are not part of the stable public API.

Note

Do not add add methods to bat_findmedian, add methods to bat_findmedian_impl instead.

source
BAT.bat_findmodeFunction
bat_findmode(
    target::BAT.MeasureLike,
    [algorithm::BAT.AbstractModeEstimator],
    [context::BATContext]
)

Estimate the global mode of target.

Returns a NamedTuple of the shape

(result = v,)

with v the estimated mode variate.

Use evalmeasure instead to obtain an EvaluatedMeasure that carries the mode together with all other evaluation results.

Implementation

bat_findmode uses evalmeasure internally. Do not specialize bat_findmode.

source
BAT.bat_initvalFunction
bat_initval(
    target::BAT.MeasureLike,
    [algorithm::BAT.InitvalAlgorithm],
    [context::BATContext]
)::V

bat_initval(
    target::BAT.MeasureLike,
    n::Integer,
    [algorithm::BAT.InitvalAlgorithm],
    [context::BATContext]
)::AbstractVector{<:V}

Generate one or n random initial/starting value(s) suitable for target.

Assuming the variates of target are of type T, returns a NamedTuple of the shape

(result = X::AbstractVector{T}, ...)

Result properties not listed here are algorithm-specific and are not part of the stable public API.

Note

Do not add add methods to bat_initval, add methods like

bat_initval_impl(target::MeasureLike, algorithm::InitvalAlgorithm, context::BATContext)
bat_initval_impl(target::MeasureLike, n::Integer, algorithm::InitvalAlgorithm, context::BATContext)

to bat_initval_impl instead.

source
BAT.bat_integrateFunction
bat_integrate(
    target::MeasureLike,
    [algorithm::IntegrationAlgorithm],
    [context::BATContext]
)

Calculate the integral (evidence) of target.

Returns a NamedTuple of the shape

(result = X,)

where X is the mass estimate, typically a Measurements.Measurement or a logarithmic number type wrapping one (e.g. for nested-sampling evidence estimates).

Use evalmeasure instead to obtain an EvaluatedMeasure that carries the mass estimate together with all other evaluation results.

Implementation

bat_integrate uses evalmeasure internally. Do not specialize bat_integrate.

source
BAT.bat_readFunction
bat_read(
    filename::AbstractString,
    [key,]
    [algorithm::BATIOAlgorithm]
)

Read data (optionally selected by key) from filename using algorithm.

Example:

smpls = bat_read("samples.hdf5", smpls).result

Returns (result = content, ...)

Result properties not listed here are specific to the output algorithm and are not part of the stable public API.

See bat_write.

Currently supported file formats are:

  • HDF5 with file extension ".h5" or ".hdf5"
Note

HDF5 I/O functionality is only available when the HDF5 package is loaded (e.g. via import HDF5).

Note

Do not add add algorithms to bat_read, add algorithms to bat_read_impl instead.

source
BAT.bat_sampleFunction
bat_sample(
    target::BAT.MeasureLike,
    [algorithm::BAT.AbstractSamplingAlgorithm],
    [context::BATContext]
)

Draw samples from target using algorithm.

Depending on sampling algorithm, the samples may be independent or correlated (e.g. when using MCMC).

Returns a NamedTuple of the shape

(result = X::DensitySampleVector,)

Use evalmeasure instead to obtain an EvaluatedMeasure that carries the samples together with all other evaluation results.

Implementation

bat_sample uses evalmeasure internally. Do not specialize bat_sample.

source
BAT.bat_writeFunction
bat_write(
    filename::AbstractString,
    content,
    [algorithm::BATIOAlgorithm]
)

Write content to file filename using algorithm.

Example:

smpls = bat_sample(posterior, ...).result
bat_write("samples.hdf5", smpls)

Returns (result = filename, ...)

Result properties not listed here are specific to the output algorithm and are not part of the stable public API.

See bat_read.

Currently supported file formats are:

  • HDF5 with file extension ".h5" or ".hdf5"
Note

HDF5 I/O functionality is only available when the HDF5 package is loaded (e.g. via import HDF5).

Note

Do not add add algorithms to bat_write, add algorithms to bat_write_impl instead.

source
BAT.bat_transformFunction
bat_transform(
    how::TransformIntent,
    object,
    [algorithm::TransformAlgorithm]
)

bat_transform(
    f,
    object,
    [algorithm::TransformAlgorithm]
)

Transform object to another variate space: either as implied by the TransformIntent how together with object, or using a given invertible transformation function f directly.

Returns a NamedTuple of the shape

(result = newdensity, f_transform = vartrafo::Function, ...)

Result properties not listed here are algorithm-specific and are not part of the stable public API.

Note

As a convenience,

flat_smpls, f_flatten = bat_transform(Vector, measure)
flat_smpls, f_flatten = bat_transform(Vector, samples)

can be used to flatten a the variate type of a measure (res. samples of a measure) to something like Vector{<:Real}.

source
BAT.evalmeasureFunction
evalmeasure(
    target::Union{AbstractMeasure,Distribution,DensitySampleVector},
    [algorithm],
    [context::BATContext]
)::EvaluatedMeasure

Evaluate measure or probability distribution target using algorithm and return an EvaluatedMeasure.

If no algorithm is given, a default will be chosen depending on the type of target. Typically, this will be an algorithm that draws (correlated or uncorrelated) samples from target, and may also yield an approximation of target and other estimates.

Implementation

evalmeasure internally runs evalmeasure_impl. Do not specialize evalmeasure directly, specialize evalmeasure_impl instead to implement new algorithms.

source
BAT.empiricalofFunction
empiricalof(m)::Union{DensitySampleMeasure,Nothing}

Get the empirical measure, based on samples drawn from measure-like object m, associated with m, or nothing if no empirical representation is available. Also see EvaluatedMeasure.

source
BAT.samplesofFunction
samplesof(m)::Union{DensitySampleVector,Nothing}

Get the samples associated with measure-like object m, or nothing if no samples are available.

The returned object is live internal data of m, it must not be modified. Use DensitySampleVector(m) or convert(DensitySampleVector, m) to obtain an independent copy from a DensitySampleMeasure or an EvaluatedMeasure with empirical samples.

source
BAT.approxofFunction
approxof(m)::Union{AbstractMeasure,Nothing}

Get an approximation of measure-like object m, or nothing if no approximation is available.

source
BAT.samplegenofFunction
samplegenof(m)::Union{BAT.AbstractSampleGenerator,Nothing}

Get the sample generation scheme associated with measure-like object m, or nothing if none has been computed. The contents of sample generators is algorithm-specific and not part of the stable API.

source
BAT.getessFunction
getess(m)::Union{Real,Nothing}

Get the (scalar) effective sample size associated with measure-like object m, or nothing if unknown.

source
BAT.evalinfoFunction
evalinfo(m)::Union{BAT.MeasureEvalInfo,Nothing}

Get information on the (last) evaluation step that generated or updated measure-like object m, or nothing if no such information is available. The contents of evaluation information is algorithm-specific and not part of the stable API.

source
BAT.get_batcontextFunction
get_batcontext()::BATContext

Gets the current default computational context for BAT.

Note: get_batcontext() does not have a stable return type. Code that needs type stability should pass a context to algorithms explicitly. BAT algorithms that call other algorithms must forward their context automatically, so context is always type stable within nested BAT algorithms.

See BATContext, set_batcontext and default_batcontext.

source
BAT.set_batcontextFunction
set_batcontext(new_context::BATContext)

set_batcontext(;
    precision = ...,
    rng = ...,
    cunit = ...,
    ad = ...
)

Sets the default computational context for BAT.

The new context becomes the process-wide default, visible to all tasks. To override the default for a dynamic scope only, bind default_batcontext via ScopedSettings.with instead - set_batcontext throws when called inside such a scope, as the scoped binding would shadow the assignment anyway.

See BATContext and get_batcontext.

source
BAT.default_batcontextConstant
default_batcontext::ScopedSettings.ScopedSetting{BATContext}

Holds the default computational context for BAT.

Unless set to a concrete BATContext object, each access default_batcontext[] yields a fresh BATContext() that includes a random number generator is seeded from Random.default_rng() (so Random.seed! makes BAT results reproducible).

set_batcontext(context) or default_batcontext[] = context) set specific BATContext process-wide. default_batcontext[] = ScopedSettings.default_value restores the default.

A context can also be bound for a dynamic scope only, inherited by tasks started within that scope:

using ScopedSettings: with

with(default_batcontext => BATContext(ad = ForwardDiff)) do
    bat_sample(target, MCMCSampling())
end

Also see get_batcontext and set_batcontext.

source
BAT.log_batdebugFunction
log_batdebug(enable::Bool = true)

Enable/disable debug-level logging for BAT and all BAT package extensions.

source
BAT.distbindFunction
distbind(f_k, dist, ::typeof(merge))

Performs a generalized monadic bind, in the functional programming sense, with a transition kernel f_k, a distribution dist, using merge to control the type of "flattening".

source
BAT.distprodFunction
distprod(;a = some_dist, b = some_other_dist, ...)
distprod(();a = some_dist, b = some_other_dist, ...))
distprod([dist1, dist2, dist2, ...])

Generate a product of distributions, returning either a distribution that has NamedTuples as variates, or arrays as variates.

source
BAT.joint_likelihoodFunction
joint_likelihood(likelihoods...)

Combine several likelihoods over a common parameter space into a joint likelihood.

All component likelihoods are evaluated at the same (i.e. shared) parameter point. The log-density of the joint likelihood is the sum of the component log-densities.

The components may be given in any form that can serve as a likelihood in a PosteriorMeasure and are converted accordingly.

MeasureBase.insupport is only defined for the joint likelihood if it is defined for all of its components.

source
BAT.lbqintegralFunction
lbqintegral(integrand, measure)
lbqintegral(likelihood, prior)

Returns an object that represents the Lebesgue integral over a function in respect to s reference measure. It is also the non-normalized posterior measure that results from integrating the likelihood of a given observation in respect to a prior measure.

source
BAT.TransformIntentType
abstract type TransformIntent

Abstract type for variate space transformation intents.

A TransformIntent, together with an object to be transformed, implies a concrete transformation function; the same intent and object always yield the same transformation. Implementations must derive the transformation from the intent and the object alone, and must support meaningful equality comparison (value-carrying intent types must specialize Base.:(==) accordingly; singleton intent types get this for free).

source
BAT.AdaptiveAffineTuningType
struct AdaptiveAffineTuning <: MCMCTransformTuning

Adaptive cycle-based MCMC tuning strategy.

Adapts an affine space transformation based on the acceptance ratio and covariance of the previous samples.

The cycle-based scale and acceptance-window scheme follows the BAT heritage implementation, see O. Schulz et al., "BAT.jl: A Julia-Based Tool for Bayesian Inference" (2021).

Constructors:

  • AdaptiveAffineTuning(; fields...)

Fields:

  • λ::Float64: Controls the weight given to new covariance information in adapting the affine transform. Default: 0.5

  • β::Float64: Controls how much the scale of the affine transform is widened/narrowed depending on the current MH acceptance ratio. Default: 1.5

  • c::IntervalSets.ClosedInterval{Float64}: Interval for allowed scale of the affine transform distribution. Default: ClosedInterval(0.0001, 100.0)

  • r::Real: Reweighting factor. Take accumulated sample statistics of previous tuning cycles into account with a relative weight of r. Set to 0 to completely reset sample statistics between each tuning cycle. Default: 0.5

source
BAT.AdaptiveMultiPropTuningType
struct AdaptiveMultiPropTuning <: MCMCProposalTuning

Tuning Algorithm for multiple MCMC Proposals. Works by adjusting the picking rule for the proposals to match the individual desired target acceptance rates based on the respective observed acceptance rates.

Constructors:

  • AdaptiveMultiPropTuning(; fields...)

Fields:

  • alpha::Float64: Default: 0.1

  • beta::Float64: Default: 0.5

  • picking_socket::Float64: Default: 0.8

source
BAT.AdaptiveTransformChainType
struct AdaptiveTransformChain <: AbstractAdaptiveTransform

A chain of adaptive space transformations, applied innermost first: x = f[end](...f[1](z)...). Tuned via MultiTrafoTuning, with one transform tuning per component.

Note: target-moment-based initializations (like PriorApproxTransformInit) are only exact for the outermost component; inner components should typically use BAT.UnitTransformInit.

Constructors:

  • AdaptiveTransformChain(f::Tuple{Vararg{AbstractAdaptiveTransform}})
source
BAT.AssumeConvergenceType

struct AssumeConvergence <: ConvergenceTest

No-op convergence algorithm for bat_convergence, will always declare convergence.

Constructors:

  • AssumeConvergence(converged::Bool = true)

Fields:

  • converged::Bool: Default: true
source
BAT.AutocorLenAlgorithmType
abstract type AutocorLenAlgorithm

Abstract type for integrated autocorrelation length estimation algorithms.

source
BAT.BATContextType
struct BATContext{T}

Set the default computational context for BAT.

Constructors:

BATContext{T}(rng::AbstractRNG, cunit::AbstractComputeUnit, ADSelector::AD)

BATContext(;
    precision::Type{<:AbstractFloat} = ...,
    rng::AbstractRNG = ...,
    cunit::HeterogeneousComputing.AbstractComputeUnit = ...,
    ad::Union{AutoDiffOperators.ADSelector, Module, Symbol, Val} = ...,
)

The default rng is seeded from Random.default_rng(), so results become reproducible via Random.seed!.

See get_batcontext, set_batcontext and default_batcontext.

source
BAT.CuhreIntegrationType
struct CuhreIntegration <: IntegrationAlgorithm

CuhreIntegration integration algorithm.

See T. Hahn, "Cuba - a library for multidimensional numerical integration" (2005).

Constructors:

  • CuhreIntegration(; fields...)

Fields:

  • pretransform::TransformIntent: Default: UniformBased()

  • rtol::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:RTOL))

  • atol::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:ATOL))

  • minevals::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MINEVALS))

  • maxevals::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MAXEVALS))

  • key::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:KEY))

  • nthreads::Int64: Default: Base.Threads.nthreads()

  • strict::Bool: Default: true

Note

This functionality is only available when the Cuba package is loaded (e.g. via import CUBA).

source
BAT.DensitySampleType
struct DensitySample

A weighted sample drawn according to an statistical density, e.g. a BAT.MeasureLike.

Constructors:

  • DensitySampleVector(v::Any, logd::Real, weight::Real, info::Any, aux::Any)

Fields:

  • v::Any: variate value

  • logd::Real: log(density) value at v

  • weight::Real: Weight of the sample

  • info::Any: Additional info on the provenance of the sample. Content depends on the sampling algorithm.

  • aux::Any: Custom user-defined information attached to the sample.

Use DensitySampleVector to store vectors of multiple samples with an efficient column-based memory layout.

source
BAT.DensitySampleMeasureType
struct DensitySampleMeasure{P,T<:Real,W<:Real,...} <: BATMeasure

Represents an Empirical Measure based on a sample of points (of type P with weights of type W) drawn from a normalizable measure, with the log-density values (of type T) of that measure at the sample points stored as well.

The sample need not have been drawn in a true IID fashion, but may also be the result of MCMC and other sampling methods.

A DensitySampleMeasure can be converted to an independent DensitySampleVector copy.

The measure snapshots the sampling weights at construction and builds a private cumulative distribution. Its values, log densities, info, and aux columns remain shared with smpls, but its sampling weights do not. Later weight changes require constructing a replacement DensitySampleMeasure. In particular, the live data returned by samplesof must not be modified: mutating its owned weights would desynchronize its cached sampling CDF.

The stored effective sample size (ess) records sampling-process provenance, not empirical-measure content. It is available through getess, but does not participate in equality or hashing.

Note: DensitySampleMeasure does not support logdensityof. An empirical measure has no density in the usual sense, the log-density values of the original measure at the sample points are available via samplesof(dsm).logd.

Constructors:

function DensitySampleMeasure(
    smpls::DensitySampleVector;
    dof::Union{IntegerLike,Nothing} = nothing,
    ess::Union{RealLike,Nothing} = nothing,
    mass::Union{RealLike,MeasureBase.AbstractUnknownMass} = 1,
)

A DensitySampleMeasure has mass one by default, as the measure the samples were drawn from is treated as implicitly normalized, even if it was a scaled probability measure of possibly unknown total mass (e.g. a non-normalized Bayesian posterior measure).

source
BAT.DensitySampleVectorType
struct DensitySampleVector <: AbstractVector{<:DensitySample}

A vector of DensitySample elements.

DensitySampleVector is currently a type alias for StructArrays.StructArray{<:DensitySample,...}, though this is subject to change without deprecation.

Constructors:

function DensitySampleVector(;
    v::AbstractVector,
    logd::AbstractVector{<:Real},
    weight::Union{AbstractVector{<:Real}, Symbol},
    info::AbstractVector,
    aux::AbstractVector
)
DensitySampleVector(
    (
        v::AbstractVector{<:AbstractVector{<:Real}},
        logd::AbstractVector{<:Real},
        weight::AbstractVector{<:Real},
        info::AbstractVector{<:Any},
        aux::AbstractVector{<:Any}
    )
)

With weight = :multiplicity repeated samples will be replaced by a single sample, with a weight equal to the number of repetitions.

source
BAT.DivonneIntegrationType
struct DivonneIntegration <: IntegrationAlgorithm

DivonneIntegration integration algorithm.

See T. Hahn, "Cuba - a library for multidimensional numerical integration" (2005).

Constructors:

  • DivonneIntegration(; fields...)

Fields:

  • pretransform::TransformIntent: Default: UniformBased()

  • rtol::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:RTOL))

  • atol::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:ATOL))

  • minevals::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MINEVALS))

  • maxevals::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MAXEVALS))

  • key1::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:KEY1))

  • key2::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:KEY2))

  • key3::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:KEY3))

  • maxpass::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MAXPASS))

  • border::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:BORDER))

  • maxchisq::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MAXCHISQ))

  • mindeviation::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MINDEVIATION))

  • ngiven::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:NGIVEN))

  • ldxgiven::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:LDXGIVEN))

  • nextra::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:NEXTRA))

  • nthreads::Int64: Default: Base.Threads.nthreads()

  • strict::Bool: Default: true

Note

This functionality is only available when the Cuba package is loaded (e.g. via import CUBA).

source
BAT.DoNotTransformType
struct DoNotTransform <: TransformIntent

The identity density transformation target, specifies that densities should not be transformed.

Constructors:

  • DoNotTransform()
source
BAT.DriftCommitScheduleType
struct DriftCommitSchedule

Transform-installation policy of FisherTransformTuning.

Geometry statistics accumulate continuously, but a new transformation is committed only when the estimated geometry has drifted far enough from the installed one: their distance in the affine-invariant SPD metric must exceed commit_threshold plus a statistical noise floor.

Early in warmup, noisy estimates drift fast and commits are frequent; as the estimate converges, commits cease on their own - there are no scheduled adaptation windows.

Constructors:

  • DriftCommitSchedule(; fields...)

Fields:

  • commit_threshold::Float64: Commit threshold in the affine-invariant SPD metric (a statistical noise floor is added automatically). Default: 0.3

  • check_interval::Int64: Steps between drift evaluations. Default: 10

  • memory_length::Int64: Steps per foreground-background estimator memory block, 0 selects an automatic, dimension-derived length. Default: 0

  • min_observations::Int64: Minimum number of accumulated observations before the first commit, 0 selects an automatic, dimension-derived count. Default: 0

source
BAT.EffSampleSizeFromACType
struct EffSampleSizeFromAC <: EffSampleSizeAlgorithm

Effective sample size estimation based on the integrated autocorrelation length of the samples - a property of the ordered sampling process.

For uniformly weighted samples the stored order is taken as the process order. Samples carrying MCMC sample ids are decomposed into their exact per-walker ordered sequences (repetition weights are expanded exactly), whose independent ESS contributions are pooled by their weight-mass fractions. For nonuniformly weighted samples without process provenance, a resample-then-autocorrelate heuristic is used - KishESS is the provenance-free alternative (and the default in that case).

A singleton has ESS one. ESS stays between one and the stored draw count. Constant, nonpositive, and antithetic autocorrelation lengths reach the upper bound. Non-finite data or estimates raise ArgumentError. Integer data uses widened centering before the FFT.

Constructors:

  • EffSampleSizeFromAC(; fields...)

Fields:

  • acalg::AutocorLenAlgorithm: Default: GeyerAutocorLen()
source
BAT.EvaluatedMeasureType
struct EvaluatedMeasure <: BATMeasure

Combines a measure with samples and other information on it.

Constructors:

em = EvaluatedMeasure(
    measure;
    transform_intent = ..., f_transform = ..., empirical = ..., approx = ...,
    dof = ..., mass = ..., modes = ..., samplegen = ..., transformed = ...,
    evalinfo = ...
)

BAT.unevaluated(em) === BAT.unevaluated(batmeasure(measure))

unevaluated(em) returns the original measure.

If measure is itself an EvaluatedMeasure, the keyword arguments update its content: given values replace the corresponding entries, ScopedSettings.unchanged (the default) keeps them, and nothing (resp. MeasureBase.UnknownMass() for mass) clears them.

An EvaluatedMeasure maintains at most one transformed-space view of its content, identified by transform_intent. Every transformed side of its BAT.BispacedMeasure entries is the representation in that flat transformed space. transform_intent === DoNotTransform() means that no view exists, f_transform is identity then by convention. The constructor checks that supplied transformed-space content is compatible with the view and rejects it with an error otherwise (see the extended help for details).

Properties:

  • unevaluated: The original measure, as a BAT.BispacedMeasure: em.unevaluated.main is the bare measure itself (returned by unevaluated(em)), em.unevaluated.transformed may cache the bare measure in the transformed space. The cache preserves object identity across repeated evaluations (keeping compiled artifacts like AD preparations valid); it is derived purely from the measure and transform_intent, so any copy is equally valid.
  • transform_intent: The TransformIntent that identifies the transformed space of this measure's content.
  • f_transform: The concrete transformation function of the view, mapping variates of the measure to the flat transformed space. Cached with the same identity-preservation rationale as the unevaluated cache. identity if no view exists, nothing if not cached.
  • empirical: A BAT.BispacedMeasure that holds a DensitySampleMeasure based on samples drawn from the measure, possibly together with a row-aligned representation of the same samples in the transformed space, or nothing if no samples are available.
  • approx: A BAT.BispacedMeasure that holds an approximation of the measure, possibly together with a representation of the same approximation in the transformed space, or nothing if no approximation is available. An approximation captures the shape of the measure, not its total mass: approximations are typically probability measures, like a normal distribution under a normalizing flow or a normalized mixture, while the measure itself is often non-normalized. Total-mass knowledge about the measure lives in mass.
  • dof: The degrees of freedom of the measure, or nothing if unknown.
  • mass: The mass of the measure, or a MeasureBase.AbstractUnknownMass if unknown.
  • modes: The modes of the measure, or nothing if unknown.
  • samplegen: An object that carries the information needed to generate further samples, or nothing if no sample generation scheme has been computed. Its contents are algorithm-specific and not part of the stable API. Like all transformed-space content it operates in the flat, unshaped transformed space, or in the unshaped space of the measure itself if no view exists. Consumers must not mutate it, continuing sample generation requires a deep copy. It is in principle independent of empirical (evalinfo records what produced the current empirical content), but for now, algorithms that replace the empirical content without using the stored scheme (like resampling and i.i.d. sampling) clear it conservatively.
  • evalinfo: Information on the (last) evaluation step that generated/updated this measure, or nothing if no evaluation has been performed or information on it is not available.

The transform_intent keyword switches the transformed-space view: ScopedSettings.unchanged means that any given transformed-space content refers to the current view. A differing intent adopts the given content and strips the transformed-space sides off all entries that are kept, including the cached transformation function unless a new f_transform is given with it. The transformed keyword updates the transformed-space cache of unevaluated with a bare measure, nothing drops the cache.

Extended help

The transformed-space view is defined by the contract

unevaluated.transformed, f_transform == transform_and_unshape(transform_intent, unevaluated.main)
empirical.main == bat_transform(inverse(f_transform), empirical.transformed).result

Equality here is by value, up to floating-point roundtrip through the inverse in the second line. The sample rows of the two empirical sides are aligned and have identical weights, the approximation pair satisfies the corresponding pushforward relation, and when f_transform is not cached the equations are understood relative to the implied transformation. The stored entries preserve the object identity of one evaluation of the pure right-hand sides, whose values do not depend on the evaluation context.

The transformed side of a BAT.BispacedMeasure pair carries the hash of the transformation it was produced under, and the constructor checks that hash against the (possibly updated) f_transform of the view. Pairs are adopted exactly when their transformed-space content is compatible with the view and rejected with an error otherwise, never silently mislabeled (up to hash collisions). This includes pairs taken from another EvaluatedMeasure of the same measure, like EvaluatedMeasure(em1, empirical = em2.empirical). The transformed and samplegen entries carry no such witness and must be accompanied by an explicit transform_intent in the same update.

The hash witnesses only that the sides of a pair are connected by the view's transformation. That the main-side content itself belongs to the measure is the responsibility of whoever supplies it, exactly as when supplying raw samples. Hashes of transformation types without a value-based hash specialization are session-bound, so their pairs are rejected after deserialization. Strip the stale view via transform_intent = DoNotTransform() and re-evaluate to recover. Use BAT.validate_evalmeasure to verify the full transformed-space-view contract explicitly.

source
BAT.ExplicitInitType
struct ExplicitInit <: InitvalAlgorithm

Uses initial values from a given vector of one or more values/variates. The values are used in the order they appear in the vector, not randomly.

Constructors:

  • ExplicitInit(; fields...)

Fields:

  • xs::AbstractVector
source
BAT.FisherTransformTuningType
struct FisherTransformTuning <: MCMCTransformTuning

Tunes MCMC space transformations for gradient-based proposals (currently HamiltonianMC and MALAProposal) by minimizing the empirical Fisher divergence of the transformed target to a standard normal distribution (following A. Seyboldt, E. L. Carlson and B. Carpenter, "Preconditioning Hamiltonian Monte Carlo by minimizing Fisher Divergence" (2026)).

For an affine transformation x = A z + μ with G = A Aᵀ, the optimum satisfies G Cov(α) G = Cov(x), where α = ∇x log(target) is the target score - the affine-invariant geometric mean of the position covariance and the inverse score covariance. For sufficiently regular targets (vanishing boundary terms) the score has zero mean and Cov(α) = E[-∇²log(target)], the average local curvature. For a Gaussian target Cov(x) = Σ while Cov(α) = Σ⁻¹, so the optimum is G = Σ. The z-space gradients that these proposals compute are mapped back through the current transformation, so no additional density or gradient evaluations are required.

Positions and scores are accumulated in the fixed pre-adaptive space with foreground-background memory (early, transient-contaminated draws are periodically forgotten). Transform updates follow the schedule; each committed transform restarts dual averaging in the step-size adaptor (see BAT.StepSizeAdaptor). HMC first searches for a reasonable step size in the new geometry, whereas MALA restarts around its current τ.

Fisher moment, fit, and validation state uses the chain's floating-point type.

Constructors:

  • FisherTransformTuning(; fields...)

Fields:

  • schedule::Any: Transform-installation policy. Default: DriftCommitSchedule()

  • regularization::Float64: Regularization added to the diagonal of both covariance estimates, relative to their mean variance scale. Default: 1.0e-5

source
BAT.FixedMGVIScheduleType
abstract type FixedMGVISchedule <: BAT.MGVISchedule

Abstract supertype for MGVI sampling schedules.

Constructors:

  • FixedMGVISchedule(; fields...)

Fields:

  • nsamples::AbstractVector{<:Real}: Default: range(12, 1000, length = 10)

Constructors:

  • FixedMGVISchedule(nsamples::AbstractVector{<:Real}): The number of samples to draw at each MGVI step. The length of nsamples implies the total number of steps. The number of samples will be rounded to integer values if necessary, to allow for constructions like FixedMGVISchedule(range(12, 1000, length = 10)).

Fields:

  • nsamples::AbstractVector{<:Real}: See constructor above.

See MGVISampling.

source
BAT.FixedNBinsType
FixedNBins(nbins::Int)

Selects a fixed number of bins.

Constructor: FixedNBins(; fields...)

Fields:

  • nbins::Int64: Default: 200
source
BAT.HamiltonianMCType
struct HamiltonianMC <: MCMCProposal

The Hamiltonian Monte Carlo (HMC) sampling algorithm, using the multinomial no-U-turn sampler (NUTS) to determine trajectory lengths dynamically.

See M. Betancourt, "A Conceptual Introduction to Hamiltonian Monte Carlo" (2017).

The Hamiltonian uses an identity mass matrix. Instead of adapting a mass matrix, BAT tunes the MCMC space transformation (see the transform_tuning option of TransformedMCMC); for affine transformations this is mathematically equivalent to adapting a constant metric, and the transformation view extends to nonlinear transports. Trajectory tuning is limited to the leapfrog step size (see BAT.StepSizeAdaptor).

HMC uses gradients of the target measure's density, so your BATContext needs to include an ADSelector to specify which automatic differentiation backend should be used.

  • Note: The fields of HamiltonianMC are still subject to change, and not

yet part of stable public BAT API!*

Constructors:

  • HamiltonianMC(; fields...)

Fields:

  • target_acceptance::Real: Default: 0.8

  • target_acceptance_int::Tuple{Vararg{Real}}: Default: (0.9target_acceptance, one(Float64))

  • step_size::Real: Leapfrog step size, NaN selects an automatic initial step size. Default: NaN

  • step_jitter::Real: Relative random variation of the step size per transition. Default: 0.0

  • max_depth::Int64: Maximum NUTS trajectory tree depth. Default: 10

  • max_delta_energy::Real: Energy error above which a trajectory is considered divergent. Default: 1000.0

source
BAT.IdentityTransformAlgorithmType
struct IdentityTransformAlgorithm <: TransformAlgorithm

A no-op density transform algorithm that leaves any density unchanged.

Constructors:

  • IdentityTransformAlgorithm()
source
BAT.MCMCGlobalProposalType
struct MCMCGlobalProposal <: MCMCProposal

MCMC proposal algorithm for drawing samples from a global proposal distribution - independent from the current position of the MCMC walker. This is an independence Metropolis-Hastings sampler, see L. Tierney, "Markov Chains for Exploring Posterior Distributions" (1994).

If no distribution is passed by the user, the target is checked for the best known approximation for the posterior, e.g. the prior.

Constructors:

  • MCMCGlobalProposal(; fields...)

Fields:

  • target_acceptance::Real: Default: 1.0

  • target_acceptance_int::Tuple{Vararg{Real}}: Default: (0.01, 1.0)

  • global_proposal::Union{Nothing, MeasureBase.AbstractMeasure, Distributions.ContinuousDistribution{<:Union{Distributions.Univariate, Distributions.Multivariate}}}: Default: nothing

source
BAT.IIDSamplingType
struct IIDSampling <: AbstractSamplingAlgorithm

Sample via Random.rand.

Constructors:

  • IIDSampling(; fields...)

Fields:

  • nsamples::Int64: Default: 10 ^ 5
source
BAT.InitFromIIDType
struct InitFromIID <: InitvalAlgorithm

Generates initial values for sampling, optimization, etc. by random resampling from a given set of samples.

Constructors:

  • InitFromIID()
source
BAT.InitFromSamplesType
struct InitFromSamples <: InitvalAlgorithm

Generates initial values for sampling, optimization, etc. by direct sampling from a given i.i.d. sampleable source.

Constructors:

  • InitFromSamples()
source
BAT.InitFromTargetType
struct InitFromTarget <: InitvalAlgorithm

Generates initial values for sampling, optimization, etc. by direct i.i.d. sampling a suitable component of that target density (e.g. it's prior) that supports it.

  • If the target supports direct i.i.d. sampling, e.g. because it is a distribution, initial values are sampled directly from the target.

  • If the target is a posterior density, initial values are sampled from the prior (or the prior's prior if the prior is a posterior itself, etc.).

  • If the target is a sampled density, initial values are (re-)sampled from the available samples.

Constructors:

  • InitFromTarget()
source
BAT.InitvalAlgorithmType
abstract type BAT.InitvalAlgorithm

Abstract type for BAT initial/starting value generation algorithms.

Many algorithms in BAT, like MCMC and optimization, need initial/starting values.

source
BAT.MALAProposalType
struct MALAProposal <: MCMCProposal

Metropolis adjusted Langevin sampling algorithm.

See G. O. Roberts and R. L. Tweedie, "Exponential convergence of Langevin distributions and their discrete approximations" (1996). The default target acceptance rate and the dimension-dependent step scaling follow G. O. Roberts and J. S. Rosenthal, "Optimal scaling of discrete approximations to Langevin diffusions" (1998); that optimality theory assumes Gaussian innovations, so with a non-Gaussian proposaldist consider setting target_acceptance explicitly.

Invalid acceptance controls or a non-finite/non-positive τ_base are rejected with ArgumentError when the MCMC state is constructed.

Constructors:

  • MALAProposal(; fields...)

Fields:

  • target_acceptance::Real: Target acceptance probability, strictly between zero and one. Default: 0.574

  • target_acceptance_int::Tuple{Vararg{Real}}: Two-element ordered acceptable tuning interval within [0, 1]. Default: (0.5, 0.65)

  • proposaldist::Union{MeasureBase.AbstractMeasure, Distributions.ContinuousDistribution{<:Union{Distributions.Univariate, Distributions.Multivariate}}}: Default: Normal()

  • τ_base::Real: Positive finite base Langevin step scale. Default: 1.65 ^ 2

source
BAT.MaxDensitySearchType
MaxDensitySearch <: AbstractModeEstimator

Constructors:

MaxDensitySearch()

Estimate the mode as the variate with the highest posterior density value within a given set of samples.

source
BAT.MCMCAlgorithmType
abstract type MCMCAlgorithm

Abstract type for Markov chain Monte Carlo algorithms.

To implement a new MCMC algorithm, subtypes of both MCMCAlgorithm and MCMCChainState are required.

Note

The details of the MCMCIterator and MCMCAlgorithm API required to implement a new MCMC algorithm currently do not (yet) form part of the stable API and are subject to change without deprecation.

source
BAT.MCMCChainPoolInitType
struct MCMCChainPoolInit <: MCMCInitAlgorithm

MCMC chain pool initialization strategy.

Constructors:

  • MCMCChainPoolInit(; fields...)

Fields:

  • init_tries_per_chain::IntervalSets.ClosedInterval{Int64}: Default: ClosedInterval(8, 128)

  • nsteps_init::Int64: Default: 1000

  • initval_alg::InitvalAlgorithm: Default: InitFromTarget()

  • strict::Bool: Default: true

source
BAT.MCMCRetryInitType
struct MCMCRetryInit <: MCMCInitAlgorithm

TODO

Constructors:

  • MCMCRetryInit(; fields...)

Fields:

  • max_init_tries::Int64: Default: 20

  • nsteps_init::Int64: Default: 250

  • initval_alg::InitvalAlgorithm: Default: InitFromTarget()

  • strict::Bool: Default: true

source
BAT.MCMCMultiCycleBurninType
struct MCMCMultiCycleBurnin <: MCMCBurninAlgorithm

A multi-cycle MCMC burn-in algorithm.

Constructors:

  • MCMCMultiCycleBurnin(; fields...)

Fields:

  • nsteps_per_cycle::Int64: Default: 10000

  • max_ncycles::Int64: Default: 30

  • nsteps_final::Int64: Default: div(nstepspercycle, 10)

source
BAT.MCMCMultiProposalType
struct MCMCMultiProposal<: MCMCProposal

MCMC sampling algorithm that allows for using multiple different proposal algorithms during sampling.

Constructors:

  • MCMCMultiProposal(; fields...)

Fields:

  • proposals::Tuple{Vararg{BAT.MCMCProposal}}

  • picking_rule::Union{Vector{<:Integer}, Distributions.Categorical{P} where P<:Real}

source
BAT.MGVISamplingType
struct MGVISampling <: AbstractUltraNestAlgorithmReactiv

Samples via Metric Gaussian Variational Inference, using the MGVI.jl Julia implementation of the algorithm.

Constructors:

  • MGVISampling(; fields...)

Fields:

  • pretransform::TransformIntent: Pre-transformation to apply to the target measure before sampling.

  • nsamples::Int: Number is independent samples to draw. MGVI will generate symmetical samples, so it will generate 2*nsamplessamples in total, but onlynsamples` independent samples.

  • schedule::MGVISchedule: MGVI schedule, by default a FixedMGVISchedule.

  • config::MGVI.MGVIConfig: MGVI configuration.

Note

This functionality is only available when the package MGVI is loaded (e.g. via import MGVI).

source
BAT.ModeAsDefinedType
struct ModeAsDefined <: AbstractModeEstimator

Get the mode as defined by the density, resp. the underlying distribution (if available), via StatsBase.mode.

Constructors:

  • ModeAsDefined()
source
BAT.MultiProposalTuningType
struct MultiProposalTuning <: MCMCProposalTuning

Tuning algorithm for MCMCMultiProposals.

Constructors:

  • MultiProposalTuning(; fields...)

Fields:

  • proposal_tunings::Tuple{Vararg{MCMCProposalTuning}}
source
BAT.MultiTrafoTuningType
struct MultiTrafoTuning <: MCMCTransformTuning

Tuning algorithm for chains of adaptive transformations (see AdaptiveTransformChain): one transform tuning per chain component, each tuning its component against the samples in that component's input/output spaces.

Score-based tunings (like FisherTransformTuning) are not supported as components yet, their score transport would require the chain rule through the other components.

Constructors:

  • MultiTrafoTuning(; fields...)

Fields:

  • trafo_tunings::Tuple{Vararg{MCMCTransformTuning}}
source
BAT.OptimAlgType
OptimAlg

Selects an optimization algorithm from the Optim.jl package as the backend for density maximization.

Used via TransformedMaxDensity for mode estimation; a bare OptimAlg used as a mode estimator is auto-wrapped in a TransformedMaxDensity with default settings.

Note that when using first order algorithms like Optim.LBFGS, your BATContext needs to include an ADSelector that specifies which automatic differentiation backend should be used.

Constructors:

  • OptimAlg(; fields...)

optimalg must be an Optim.AbstractOptimizer.

Fields:

  • optalg::Any: Default: extdefault(pkgext(Val(:Optim)), Val(:DEFAULTOPTALG))

  • maxiters::Int64: Default: 1000

  • maxtime::Float64: Default: NaN

  • abstol::Float64: Default: NaN

  • reltol::Float64: Default: 0.0

  • store_trace::Bool: Default: false

  • kwargs::NamedTuple: Default: (;)

Note

This algorithm is only available if the Optim package is loaded (e.g. via import Optim.

source
BAT.OptimizationAlgType
struct OptimizationAlg

Selects an optimization algorithm from the OptimizationBase.jl package as the backend for density maximization.

Used via TransformedMaxDensity for mode estimation; a bare OptimizationAlg used as a mode estimator is auto-wrapped in a TransformedMaxDensity with default settings.

Note that when using first order algorithms like OptimizationOptimJL.LBFGS, your BATContext needs to have ad set to an automatic differentiation backend.

Constructors:

  • OptimizationAlg(; fields...)

optalg must be an OptimizationBase.AbstractOptimizer. The field kwargs can be used to pass additional keywords to the optimizers See the OptimizationBase.jl documentation for the available keyword arguments. Fields:

  • optalg::Any: Default: extdefault(pkgext(Val(:OptimizationBase)), Val(:DEFAULTOPTALG))

  • maxiters::Int64: Default: 1000

  • maxtime::Float64: Default: NaN

  • abstol::Float64: Default: NaN

  • reltol::Float64: Default: 0.0

  • store_trace::Bool: Default: false

  • kwargs::NamedTuple: Default: (;)

Note

This algorithm is only available if the OptimizationBase package or any of its submodules, like OptimizationOptimJL, is loaded (e.g. via import OptimizationOptimJL).

source
BAT.PosteriorMeasureType
struct PosteriorMeasure{Li,Pr<:AbstractMeasure} <: AbstractPosteriorMeasure

A representation of a PosteriorMeasure, based a likelihood and prior. Likelihood and prior be accessed via

getlikelihood(posterior::PosteriorMeasure)::Li
getprior(posterior::PosteriorMeasure)::Pr

Constructors:

  • PosteriorMeasure(likelihood, prior)
  • PosteriorMeasure{T<:Real}(likelihood, prior)

Fields:

  • likelihood::Any

  • prior::MeasureBase.AbstractMeasure

source
BAT.PriorSubstitutionType
struct PriorSubstitution <: TransformAlgorithm

Substitute the prior by a given distribution and transform the likelihood accordingly. The log(abs(jacobian)) of the transformation does not need to be auto-differentiable even for operations that use the gradient of the posterior.

Constructors:

  • PriorSubstitution()
source
BAT.NormalBasedType
struct NormalBased <: TransformIntent

Specifies that the target measure of an operation should be transformed so that it is based on a standard multivariate normal distribution: the prior — descending through nested posteriors to the innermost prior — becomes standard normal. Applies to any measure with such a transformable base, not just posteriors.

Constructors:

  • NormalBased()
source
BAT.UniformBasedType
struct UniformBased <: TransformIntent

Specifies that the target measure of an operation should be transformed so that it is based on a uniform distribution over the unit hypercube: the prior — descending through nested posteriors to the innermost prior — becomes standard uniform. Applies to any measure with such a transformable base, not just posteriors.

Constructors:

  • UniformBased()
source
BAT.RAMTuningType
struct RAMTuning <: MCMCTransformTuning

Tunes MCMC spaces transformations based on M. Vihola, "Robust adaptive Metropolis algorithm with coerced acceptance rate" (2012).

In constrast to the original RAM algorithm, RAMTuning does not use the covariance estimate to change a proposal distribution, but instead uses it as the bases for an affine transformation. The sampling process is mathematically equivalent, though.

Constructors:

  • RAMTuning(; fields...)

Fields:

  • gamma::Float64: Negative adaption rate exponent. Default: 2 / 3
source
BAT.RandomWalkType
struct RandomWalk <: MCMCProposal

Metropolis-Hastings MCMC sampling algorithm.

For Gaussian random-walk Metropolis in the high-dimensional symmetric product-target regime, the asymptotic target acceptance rate and proposal scaling are G. O. Roberts, A. Gelman and W. R. Gilks, "Weak convergence and optimal scaling of random walk Metropolis algorithms" (1997).

BAT applies the same scale heuristically to its default Cauchy (TDist(1)) innovation.

Constructors:

  • RandomWalk(; fields...)

Fields:

  • target_acceptance::Real: Default: 0.234

  • target_acceptance_int::Tuple{Vararg{Real}}: Default: (0.15, 0.35)

  • proposaldist::Union{MeasureBase.AbstractMeasure, Distributions.ContinuousDistribution{<:Union{Distributions.Univariate, Distributions.Multivariate}}}: Default: TDist(1.0)

source
BAT.RandResamplingType
struct RandResampling <: AbstractSamplingAlgorithm

Resamples from a given set of samples.

Constructors:

  • RandResampling(; fields...)

Fields:

  • nsamples::Int64: Default: 10 ^ 5
source
BAT.RepetitionWeightingType
struct RepetitionWeighting{T<:AbstractFloat} <: AbstractMCMCWeightingScheme{T}

Sample weighting scheme suitable for sampling algorithms which may repeated samples multiple times in direct succession (e.g. RandomWalk). The repeated sample is stored only once, with a weight equal to the number of times it has been repeated (e.g. because a Markov chain has not moved during a sampling step).

Constructors:

  • RepetitionWeighting()
source
BAT.SampleMedianEstimatorType
struct SampleMedianEstimator <: AbstractMedianEstimator

Get median values from samples using standard Julia statistics functions.

Constructors:

  • SampleMedianEstimator()
source
BAT.SuaveIntegrationType
struct SuaveIntegration <: IntegrationAlgorithm

SuaveIntegration integration algorithm.

See T. Hahn, "Cuba - a library for multidimensional numerical integration" (2005).

Constructors:

  • SuaveIntegration(; fields...)

Fields:

  • pretransform::TransformIntent: Default: UniformBased()

  • rtol::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:RTOL))

  • atol::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:ATOL))

  • minevals::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MINEVALS))

  • maxevals::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MAXEVALS))

  • nnew::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:NNEW))

  • nmin::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:NMIN))

  • flatness::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:FLATNESS))

  • nthreads::Int64: Default: Base.Threads.nthreads()

  • strict::Bool: Default: true

Note

This functionality is only available when the Cuba package is loaded (e.g. via import CUBA).

source
BAT.SystematicResamplingType
struct SystematicResampling <: AbstractSamplingAlgorithm

Systematic resampling from a given series of samples, keeping the order of the samples: a single stratified uniform yields exactly nsamples draws in one order-preserving pass. It typically gives lower variance than multinomial resampling, though its conditional variance is ordering-dependent and does not uniformly dominate the other standard resampling schemes.

See G. Kitagawa, "Monte Carlo Filter and Smoother for Non-Gaussian Nonlinear State Space Models", J. Comput. Graph. Stat. 5(1) (1996).

Can be used to efficiently convert weighted samples into samples with unity weights.

Constructors:

  • SystematicResampling(; fields...)

Fields:

  • nsamples::Int64: Default: 10 ^ 5
source
BAT.ToRealVectorType
struct ToRealVector <: TransformIntent

Specifies that the input should be transformed into a measure over the space of real-valued flat vectors.

Constructors:

  • ToRealVector()
source
BAT.TransformedMaxDensityType
struct TransformedMaxDensity <: AbstractModeEstimator

Estimates the mode of a measure by maximizing its density numerically, searching in a transformed space.

The search runs in the space induced by pretransform without applying the transformation's volume correction, so the result is a mode of the original density, not of the transformed one.

Constructors:

  • TransformedMaxDensity(; fields...)

Fields:

  • optalg::Union{OptimAlg, OptimizationAlg}: Density maximization backend. Default: OptimAlg()

  • pretransform::TransformIntent: Target space transformation to search in. Default: NormalBased()

  • init::InitvalAlgorithm: Initial point selection, applied in the transformed space. Default: InitFromTarget()

source
BAT.TransformedMCMCType
struct TransformedMCMC <: AbstractSamplingAlgorithm

Samples a probability density using Markov chain Monte Carlo.

Constructors:

  • TransformedMCMC(; fields...)

Fields:

  • proposal::BAT.MCMCProposal: Default: RandomWalk(proposaldist = TDist(1.0))

  • proposal_tuning::MCMCProposalTuning: Default: batdefault(TransformedMCMC, Val(:proposaltuning), proposal)

  • pretransform::TransformIntent: Default: bat_default(TransformedMCMC, Val(:pretransform), proposal)

  • adaptive_transform::BAT.AbstractAdaptiveTransform: Default: batdefault(TransformedMCMC, Val(:adaptivetransform), proposal)

  • transform_tuning::MCMCTransformTuning: Default: batdefault(TransformedMCMC, Val(:transformtuning), proposal, adaptive_transform)

  • tempering::MCMCTempering: Default: bat_default(TransformedMCMC, Val(:tempering), proposal)

  • nchains::Int64: Default: 4

  • nwalkers::Int64: Default: batdefault(TransformedMCMC, Val(:nwalkers), proposal, pretransform, transformtuning, nchains)

  • nsteps::Int64: Default: batdefault(TransformedMCMC, Val(:nsteps), proposal, pretransform, transformtuning, nchains, nwalkers)

  • init::MCMCInitAlgorithm: Default: batdefault(TransformedMCMC, Val(:init), proposal, pretransform, transformtuning, nchains, nwalkers, nsteps)

  • burnin::MCMCBurninAlgorithm: Default: batdefault(TransformedMCMC, Val(:burnin), proposal, pretransform, transformtuning, nchains, nwalkers, nsteps)

  • convergence::BAT.ConvergenceTest: Default: BrooksGelmanConvergence()

  • strict::Bool: Default: true

  • store_burnin::Bool: Default: false

  • nonzero_weights::Bool: Default: true

  • sample_weighting::AbstractMCMCWeightingScheme: Default: RepetitionWeighting()

  • callback::Function: Default: nop_func

source
BAT.VEGASIntegrationType
struct VEGASIntegration <: IntegrationAlgorithm

VEGASIntegration integration algorithm.

See T. Hahn, "Cuba - a library for multidimensional numerical integration" (2005).

Constructors:

  • VEGASIntegration(; fields...)

Fields:

  • pretransform::TransformIntent: Default: UniformBased()

  • rtol::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:RTOL))

  • atol::Float64: Default: ext_default(pkgext(Val(:Cuba)), Val(:ATOL))

  • minevals::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MINEVALS))

  • maxevals::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:MAXEVALS))

  • nstart::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:NSTART))

  • nincrease::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:NINCREASE))

  • nbatch::Int64: Default: ext_default(pkgext(Val(:Cuba)), Val(:NBATCH))

  • nthreads::Int64: Default: Base.Threads.nthreads()

  • strict::Bool: Default: true

Note

This functionality is only available when the Cuba package is loaded (e.g. via import CUBA).

source
BAT.unevaluatedFunction
BAT.unevaluated(obj)

If obj is an evaluated object, like a EvaluatedMeasure, return the original (unevaluated) object. Otherwise, return obj.

This is the explicit way to strip attached measure knowledge, e.g. to obtain a bare measure for performance-critical density evaluation. Reparametrizations like unshaped transport attached knowledge instead of dropping it.

source
BAT.ConvergenceTestType
abstract type ConvergenceTest

Abstract type for integrated autocorrelation length estimation algorithms.

source