API Documentation
This is the stable public API of BAT. Forward/backward compatibility follows Julia's semantic versioning rules.
Types
BAT.AbstractMCMCWeightingSchemeBAT.AbstractMedianEstimatorBAT.AbstractModeEstimatorBAT.AbstractPosteriorMeasureBAT.AbstractSamplingAlgorithmBAT.AdaptiveAffineTuningBAT.AdaptiveMultiPropTuningBAT.AdaptiveTransformChainBAT.AssumeConvergenceBAT.AutocorLenAlgorithmBAT.BATContextBAT.BATHDF5IOBAT.BATIOAlgorithmBAT.BinningAlgorithmBAT.BrooksGelmanConvergenceBAT.ConvergenceTestBAT.CuhreIntegrationBAT.DensitySampleBAT.DensitySampleMeasureBAT.DensitySampleVectorBAT.DivonneIntegrationBAT.DoNotTransformBAT.DriftCommitScheduleBAT.EffSampleSizeAlgorithmBAT.EffSampleSizeFromACBAT.EvaluatedMeasureBAT.ExplicitInitBAT.FisherTransformTuningBAT.FixedMGVIScheduleBAT.FixedNBinsBAT.FreedmanDiaconisBinningBAT.GelmanRubinConvergenceBAT.GeyerAutocorLenBAT.HamiltonianMCBAT.IIDSamplingBAT.IdentityTransformAlgorithmBAT.InitFromIIDBAT.InitFromSamplesBAT.InitFromTargetBAT.InitvalAlgorithmBAT.IntegrationAlgorithmBAT.KishESSBAT.MALAProposalBAT.MCMCAlgorithmBAT.MCMCBurninAlgorithmBAT.MCMCChainPoolInitBAT.MCMCGlobalProposalBAT.MCMCInitAlgorithmBAT.MCMCMultiCycleBurninBAT.MCMCMultiProposalBAT.MCMCProposalTuningBAT.MCMCRetryInitBAT.MCMCTransformTuningBAT.MGVISamplingBAT.MGVIScheduleBAT.MaxDensitySearchBAT.ModeAsDefinedBAT.MultiProposalTuningBAT.MultiTrafoTuningBAT.NoMCMCProposalTuningBAT.NoMCMCTransformTuningBAT.NormalBasedBAT.OptimAlgBAT.OptimizationAlgBAT.PosteriorMeasureBAT.PriorSubstitutionBAT.RAMTuningBAT.RandResamplingBAT.RandomWalkBAT.RepetitionWeightingBAT.RiceBinningBAT.SampleMedianEstimatorBAT.ScottBinningBAT.SokalAutocorLenBAT.SquareRootBinningBAT.SturgesBinningBAT.SuaveIntegrationBAT.SystematicResamplingBAT.ToRealVectorBAT.TransformAlgorithmBAT.TransformIntentBAT.TransformedMCMCBAT.TransformedMaxDensityBAT.UniformBasedBAT.VEGASIntegration
Functions and macros
BAT.approxofBAT.bat_bgmlBAT.bat_convergenceBAT.bat_defaultBAT.bat_eff_sample_sizeBAT.bat_findmedianBAT.bat_findmodeBAT.bat_initvalBAT.bat_integrateBAT.bat_readBAT.bat_sampleBAT.bat_transformBAT.bat_writeBAT.distbindBAT.distprodBAT.empiricalofBAT.evalinfoBAT.evalmeasureBAT.get_batcontextBAT.getessBAT.joint_likelihoodBAT.lbqintegralBAT.log_batdebugBAT.samplegenofBAT.samplesofBAT.set_batcontextBAT.unevaluated
Documentation
BAT.bat_bgml — Function
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, ...)BAT.bat_convergence — Function
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.
BAT.bat_default — Function
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()BAT.bat_eff_sample_size — Function
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.
BAT.bat_findmedian — Function
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.
BAT.bat_findmode — Function
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.
BAT.bat_initval — Function
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.
BAT.bat_integrate — Function
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.
BAT.bat_read — Function
bat_read(
filename::AbstractString,
[key,]
[algorithm::BATIOAlgorithm]
)Read data (optionally selected by key) from filename using algorithm.
Example:
smpls = bat_read("samples.hdf5", smpls).resultReturns (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"
HDF5 I/O functionality is only available when the HDF5 package is loaded (e.g. via import HDF5).
BAT.bat_sample — Function
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.
BAT.bat_write — Function
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"
HDF5 I/O functionality is only available when the HDF5 package is loaded (e.g. via import HDF5).
BAT.bat_transform — Function
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.
BAT.evalmeasure — Function
evalmeasure(
target::Union{AbstractMeasure,Distribution,DensitySampleVector},
[algorithm],
[context::BATContext]
)::EvaluatedMeasureEvaluate 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.
BAT.empiricalof — Function
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.
BAT.samplesof — Function
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.
BAT.approxof — Function
approxof(m)::Union{AbstractMeasure,Nothing}Get an approximation of measure-like object m, or nothing if no approximation is available.
BAT.samplegenof — Function
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.
BAT.getess — Function
getess(m)::Union{Real,Nothing}Get the (scalar) effective sample size associated with measure-like object m, or nothing if unknown.
BAT.evalinfo — Function
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.
BAT.get_batcontext — Function
get_batcontext()::BATContextGets 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.
BAT.set_batcontext — Function
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.
BAT.default_batcontext — Constant
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())
endAlso see get_batcontext and set_batcontext.
BAT.log_batdebug — Function
log_batdebug(enable::Bool = true)Enable/disable debug-level logging for BAT and all BAT package extensions.
BAT.distbind — Function
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".
BAT.distprod — Function
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.
BAT.joint_likelihood — Function
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.
BAT.lbqintegral — Function
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.
BAT.AbstractMCMCWeightingScheme — Type
abstract type AbstractMCMCWeightingScheme{T<:Real}Abstract class for weighting schemes for MCMC samples.
Weight values will have type T.
BAT.AbstractPosteriorMeasure — Type
abstract type AbstractPosteriorMeasure <: BATMeasure endAbstract type for posterior probability densities.
BAT.TransformIntent — Type
abstract type TransformIntentAbstract 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).
BAT.AdaptiveAffineTuning — Type
struct AdaptiveAffineTuning <: MCMCTransformTuningAdaptive 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.5c::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 ofr. Set to0to completely reset sample statistics between each tuning cycle. Default: 0.5
BAT.AdaptiveMultiPropTuning — Type
struct AdaptiveMultiPropTuning <: MCMCProposalTuningTuning 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.1beta::Float64: Default: 0.5picking_socket::Float64: Default: 0.8
BAT.AdaptiveTransformChain — Type
struct AdaptiveTransformChain <: AbstractAdaptiveTransformA 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}})
BAT.AssumeConvergence — Type
struct AssumeConvergence <: ConvergenceTest
No-op convergence algorithm for bat_convergence, will always declare convergence.
Constructors:
AssumeConvergence(converged::Bool = true)
Fields:
converged::Bool: Default: true
BAT.AutocorLenAlgorithm — Type
abstract type AutocorLenAlgorithmAbstract type for integrated autocorrelation length estimation algorithms.
BAT.BATContext — Type
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.
BAT.BATHDF5IO — Type
struct BATHDF5IO <: BATIOAlgorithmSelects the BAT HDF5 format as the output format.
Constructors:
BATHDF5IO()
BAT.BATIOAlgorithm — Type
abstract type BATIOAlgorithmAbstract type for density transformation algorithms.
BAT.BinningAlgorithm — Type
abstract type BinningAlgorithmAbstract type for binning algorithms.
BAT.BrooksGelmanConvergence — Type
struct BrooksGelmanConvergence <: ConvergenceTestBrooks-Gelman maximum R^2 convergence test.
Constructors:
BrooksGelmanConvergence(; fields...)
Fields:
threshold::Float64: Default: 1.1corrected::Bool: Default: false
BAT.CuhreIntegration — Type
struct CuhreIntegration <: IntegrationAlgorithmCuhreIntegration 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
This functionality is only available when the Cuba package is loaded (e.g. via import CUBA).
BAT.DensitySample — Type
struct DensitySampleA 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 valuelogd::Real: log(density) value atvweight::Real: Weight of the sampleinfo::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.
BAT.DensitySampleMeasure — Type
struct DensitySampleMeasure{P,T<:Real,W<:Real,...} <: BATMeasureRepresents 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).
BAT.DensitySampleVector — Type
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.
BAT.DivonneIntegration — Type
struct DivonneIntegration <: IntegrationAlgorithmDivonneIntegration 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
This functionality is only available when the Cuba package is loaded (e.g. via import CUBA).
BAT.DoNotTransform — Type
struct DoNotTransform <: TransformIntentThe identity density transformation target, specifies that densities should not be transformed.
Constructors:
DoNotTransform()
BAT.DriftCommitSchedule — Type
struct DriftCommitScheduleTransform-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.3check_interval::Int64: Steps between drift evaluations. Default: 10memory_length::Int64: Steps per foreground-background estimator memory block,0selects an automatic, dimension-derived length. Default: 0min_observations::Int64: Minimum number of accumulated observations before the first commit,0selects an automatic, dimension-derived count. Default: 0
BAT.EffSampleSizeAlgorithm — Type
abstract type EffSampleSizeAlgorithmAbstract type for integrated autocorrelation length estimation algorithms.
BAT.EffSampleSizeFromAC — Type
struct EffSampleSizeFromAC <: EffSampleSizeAlgorithmEffective 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()
BAT.EvaluatedMeasure — Type
struct EvaluatedMeasure <: BATMeasureCombines 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 aBAT.BispacedMeasure:em.unevaluated.mainis the bare measure itself (returned byunevaluated(em)),em.unevaluated.transformedmay 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 andtransform_intent, so any copy is equally valid.transform_intent: TheTransformIntentthat 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 theunevaluatedcache.identityif no view exists,nothingif not cached.empirical: ABAT.BispacedMeasurethat holds aDensitySampleMeasurebased on samples drawn from the measure, possibly together with a row-aligned representation of the same samples in the transformed space, ornothingif no samples are available.approx: ABAT.BispacedMeasurethat holds an approximation of the measure, possibly together with a representation of the same approximation in the transformed space, ornothingif 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 inmass.dof: The degrees of freedom of the measure, ornothingif unknown.mass: The mass of the measure, or aMeasureBase.AbstractUnknownMassif unknown.modes: The modes of the measure, ornothingif unknown.samplegen: An object that carries the information needed to generate further samples, ornothingif 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 ofempirical(evalinforecords 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, ornothingif 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).resultEquality 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.
BAT.ExplicitInit — Type
struct ExplicitInit <: InitvalAlgorithmUses 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
BAT.FisherTransformTuning — Type
struct FisherTransformTuning <: MCMCTransformTuningTunes 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
BAT.FixedMGVISchedule — Type
abstract type FixedMGVISchedule <: BAT.MGVIScheduleAbstract 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 ofnsamplesimplies the total number of steps. The number of samples will be rounded to integer values if necessary, to allow for constructions likeFixedMGVISchedule(range(12, 1000, length = 10)).
Fields:
nsamples::AbstractVector{<:Real}: See constructor above.
See MGVISampling.
BAT.FixedNBins — Type
FixedNBins(nbins::Int)Selects a fixed number of bins.
Constructor: FixedNBins(; fields...)
Fields:
nbins::Int64: Default: 200
BAT.FreedmanDiaconisBinning — Type
struct FreedmanDiaconisBinning <: BinningAlgorithmSelects automatic binning based on the Freedman–Diaconis rule.
See D. Freedman and P. Diaconis, "On the histogram as a density estimator: L2 theory" (1981).
Constructor: FreedmanDiaconisBinning()
BAT.GelmanRubinConvergence — Type
struct GelmanRubinConvergence <: ConvergenceTestGelman-Rubin maximum R^2 convergence test.
See A. Gelman and D. B. Rubin, "Inference from Iterative Simulation Using Multiple Sequences" (1992).
Constructors:
GelmanRubinConvergence(; fields...)
Fields:
threshold::Float64: Default: 1.1
BAT.GeyerAutocorLen — Type
struct GeyerAutocorLen <: AutocorLenAlgorithmIntegrated autocorrelation length estimation based on Geyer’s initial monotone sequence criterion
See C. J. Geyer, "Practical Markov Chain Monte Carlo" (1992) and C. J. Geyer, "Introduction to Markov Chain Monte Carlo" (2011).
Constructors:
GeyerAutocorLen()
The same algorithm is used by STAN (v2.21) and MCMCChains.jl (v3.0, function ess_rhat).
BAT.HamiltonianMC — Type
struct HamiltonianMC <: MCMCProposalThe 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
HamiltonianMCare still subject to change, and not
yet part of stable public BAT API!*
Constructors:
HamiltonianMC(; fields...)
Fields:
target_acceptance::Real: Default: 0.8target_acceptance_int::Tuple{Vararg{Real}}: Default: (0.9target_acceptance, one(Float64))step_size::Real: Leapfrog step size,NaNselects an automatic initial step size. Default: NaNstep_jitter::Real: Relative random variation of the step size per transition. Default: 0.0max_depth::Int64: Maximum NUTS trajectory tree depth. Default: 10max_delta_energy::Real: Energy error above which a trajectory is considered divergent. Default: 1000.0
BAT.IdentityTransformAlgorithm — Type
struct IdentityTransformAlgorithm <: TransformAlgorithmA no-op density transform algorithm that leaves any density unchanged.
Constructors:
IdentityTransformAlgorithm()
BAT.MCMCGlobalProposal — Type
struct MCMCGlobalProposal <: MCMCProposalMCMC 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.0target_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
BAT.IIDSampling — Type
struct IIDSampling <: AbstractSamplingAlgorithmSample via Random.rand.
Constructors:
IIDSampling(; fields...)
Fields:
nsamples::Int64: Default: 10 ^ 5
BAT.InitFromIID — Type
struct InitFromIID <: InitvalAlgorithmGenerates initial values for sampling, optimization, etc. by random resampling from a given set of samples.
Constructors:
InitFromIID()
BAT.InitFromSamples — Type
struct InitFromSamples <: InitvalAlgorithmGenerates initial values for sampling, optimization, etc. by direct sampling from a given i.i.d. sampleable source.
Constructors:
InitFromSamples()
BAT.InitFromTarget — Type
struct InitFromTarget <: InitvalAlgorithmGenerates 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()
BAT.InitvalAlgorithm — Type
abstract type BAT.InitvalAlgorithmAbstract type for BAT initial/starting value generation algorithms.
Many algorithms in BAT, like MCMC and optimization, need initial/starting values.
BAT.IntegrationAlgorithm — Type
abstract type IntegrationAlgorithmAbstract type for integration algorithms.
BAT.KishESS — Type
struct KishESS <: EffSampleSizeAlgorithmKish's effective sample size estimator, uses only the sample weights.
See L. Kish, "Survey Sampling", John Wiley & Sons (1965), and effective sample size of weighted samples.
Constructors:
KishESS()
BAT.MALAProposal — Type
struct MALAProposal <: MCMCProposalMetropolis 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.574target_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
BAT.MaxDensitySearch — Type
MaxDensitySearch <: AbstractModeEstimatorConstructors:
MaxDensitySearch()Estimate the mode as the variate with the highest posterior density value within a given set of samples.
BAT.MCMCAlgorithm — Type
abstract type MCMCAlgorithmAbstract type for Markov chain Monte Carlo algorithms.
To implement a new MCMC algorithm, subtypes of both MCMCAlgorithm and MCMCChainState are required.
BAT.MCMCBurninAlgorithm — Type
abstract type MCMCBurninAlgorithmAbstract type for MCMC burn-in algorithms.
BAT.MCMCChainPoolInit — Type
struct MCMCChainPoolInit <: MCMCInitAlgorithmMCMC chain pool initialization strategy.
Constructors:
MCMCChainPoolInit(; fields...)
Fields:
init_tries_per_chain::IntervalSets.ClosedInterval{Int64}: Default: ClosedInterval(8, 128)nsteps_init::Int64: Default: 1000initval_alg::InitvalAlgorithm: Default: InitFromTarget()strict::Bool: Default: true
BAT.MCMCRetryInit — Type
struct MCMCRetryInit <: MCMCInitAlgorithmTODO
Constructors:
MCMCRetryInit(; fields...)
Fields:
max_init_tries::Int64: Default: 20nsteps_init::Int64: Default: 250initval_alg::InitvalAlgorithm: Default: InitFromTarget()strict::Bool: Default: true
BAT.MCMCInitAlgorithm — Type
abstract type MCMCInitAlgorithmAbstract type for MCMC initialization algorithms.
BAT.MCMCMultiCycleBurnin — Type
struct MCMCMultiCycleBurnin <: MCMCBurninAlgorithmA multi-cycle MCMC burn-in algorithm.
Constructors:
MCMCMultiCycleBurnin(; fields...)
Fields:
nsteps_per_cycle::Int64: Default: 10000max_ncycles::Int64: Default: 30nsteps_final::Int64: Default: div(nstepspercycle, 10)
BAT.MCMCMultiProposal — Type
struct MCMCMultiProposal<: MCMCProposalMCMC 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}
BAT.MCMCProposalTuning — Type
abstract type MCMCProposalTuningAbstract type for MCMC tuning algorithms.
BAT.MCMCTransformTuning — Type
abstract type MCMCTransformTuningAbstract type for MCMC tuning algorithms.
BAT.MGVISampling — Type
struct MGVISampling <: AbstractUltraNestAlgorithmReactivSamples 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 generate2*nsamplessamples in total, but onlynsamples` independent samples.schedule::MGVISchedule: MGVI schedule, by default aFixedMGVISchedule.config::MGVI.MGVIConfig: MGVI configuration.
This functionality is only available when the package MGVI is loaded (e.g. via import MGVI).
BAT.ModeAsDefined — Type
struct ModeAsDefined <: AbstractModeEstimatorGet the mode as defined by the density, resp. the underlying distribution (if available), via StatsBase.mode.
Constructors:
ModeAsDefined()
BAT.MultiProposalTuning — Type
struct MultiProposalTuning <: MCMCProposalTuningTuning algorithm for MCMCMultiProposals.
Constructors:
MultiProposalTuning(; fields...)
Fields:
proposal_tunings::Tuple{Vararg{MCMCProposalTuning}}
BAT.MultiTrafoTuning — Type
struct MultiTrafoTuning <: MCMCTransformTuningTuning 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}}
BAT.NoMCMCProposalTuning — Type
NoMCMCProposalTuning <: MCMCProposalTuningDo not perform any MCMC proposal tuning.
BAT.NoMCMCTransformTuning — Type
NoMCMCTransformTuning <: MCMCTransformTuningDo not perform any MCMC transform tuning.
BAT.OptimAlg — Type
OptimAlgSelects 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: 1000maxtime::Float64: Default: NaNabstol::Float64: Default: NaNreltol::Float64: Default: 0.0store_trace::Bool: Default: falsekwargs::NamedTuple: Default: (;)
BAT.OptimizationAlg — Type
struct OptimizationAlgSelects 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: 1000maxtime::Float64: Default: NaNabstol::Float64: Default: NaNreltol::Float64: Default: 0.0store_trace::Bool: Default: falsekwargs::NamedTuple: Default: (;)
BAT.PosteriorMeasure — Type
struct PosteriorMeasure{Li,Pr<:AbstractMeasure} <: AbstractPosteriorMeasureA representation of a PosteriorMeasure, based a likelihood and prior. Likelihood and prior be accessed via
getlikelihood(posterior::PosteriorMeasure)::Li
getprior(posterior::PosteriorMeasure)::PrConstructors:
PosteriorMeasure(likelihood, prior)PosteriorMeasure{T<:Real}(likelihood, prior)
Fields:
likelihood::Anyprior::MeasureBase.AbstractMeasure
BAT.PriorSubstitution — Type
struct PriorSubstitution <: TransformAlgorithmSubstitute 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()
BAT.NormalBased — Type
struct NormalBased <: TransformIntentSpecifies 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()
BAT.UniformBased — Type
struct UniformBased <: TransformIntentSpecifies 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()
BAT.RAMTuning — Type
struct RAMTuning <: MCMCTransformTuningTunes 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
BAT.RandomWalk — Type
struct RandomWalk <: MCMCProposalMetropolis-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.234target_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)
BAT.RandResampling — Type
struct RandResampling <: AbstractSamplingAlgorithmResamples from a given set of samples.
Constructors:
RandResampling(; fields...)
Fields:
nsamples::Int64: Default: 10 ^ 5
BAT.RepetitionWeighting — Type
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()
BAT.RiceBinning — Type
struct RiceBinning <: BinningAlgorithmSelects automatic binning based on the Rice rule.
Constructor: RiceBinning()
BAT.SampleMedianEstimator — Type
struct SampleMedianEstimator <: AbstractMedianEstimatorGet median values from samples using standard Julia statistics functions.
Constructors:
SampleMedianEstimator()
BAT.ScottBinning — Type
struct ScottBinning <: BinningAlgorithmSelects automatic binning based on Scott's normal reference rule.
See D. W. Scott, "On optimal and data-based histograms" (1979).
Constructor: ScottBinning()
BAT.SokalAutocorLen — Type
struct SokalAutocorLen <: AutocorLenAlgorithmIntegrated autocorrelation length estimation based on the automated windowing procedure descibed in A. D. Sokal, "Monte Carlo Methods in Statistical Mechanics" (1996)
Same procedure is used by the emcee Python package (v3.0).
Constructors:
SokalAutocorLen(; fields...)
Fields:
c::Int64: Step size for window search Default: 5
BAT.SquareRootBinning — Type
struct SquareRootBinning <: BinningAlgorithmSelects automatic binning based on the Square-root choice.
Constructor: SquareRootBinning()
BAT.SturgesBinning — Type
struct SturgesBinning <: BinningAlgorithmSelects automatic binning based on Sturges' formula.
See H. A. Sturges, "The Choice of a Class Interval" (1926).
Constructor: SturgesBinning()
BAT.SuaveIntegration — Type
struct SuaveIntegration <: IntegrationAlgorithmSuaveIntegration 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
This functionality is only available when the Cuba package is loaded (e.g. via import CUBA).
BAT.SystematicResampling — Type
struct SystematicResampling <: AbstractSamplingAlgorithmSystematic 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.
Can be used to efficiently convert weighted samples into samples with unity weights.
Constructors:
SystematicResampling(; fields...)
Fields:
nsamples::Int64: Default: 10 ^ 5
BAT.ToRealVector — Type
struct ToRealVector <: TransformIntentSpecifies that the input should be transformed into a measure over the space of real-valued flat vectors.
Constructors:
ToRealVector()
BAT.TransformAlgorithm — Type
abstract type TransformAlgorithmAbstract type for density transformation algorithms.
BAT.TransformedMaxDensity — Type
struct TransformedMaxDensity <: AbstractModeEstimatorEstimates 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()
BAT.TransformedMCMC — Type
struct TransformedMCMC <: AbstractSamplingAlgorithmSamples 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: 4nwalkers::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: truestore_burnin::Bool: Default: falsenonzero_weights::Bool: Default: truesample_weighting::AbstractMCMCWeightingScheme: Default: RepetitionWeighting()callback::Function: Default: nop_func
BAT.VEGASIntegration — Type
struct VEGASIntegration <: IntegrationAlgorithmVEGASIntegration 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
This functionality is only available when the Cuba package is loaded (e.g. via import CUBA).
BAT.unevaluated — Function
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.
BAT.AbstractMedianEstimator — Type
abstract type BAT.AbstractMedianEstimatorAbstract type for BAT median estimation algorithms (see bat_findmedian).
BAT.AbstractModeEstimator — Type
abstract type BAT.AbstractModeEstimatorAbstract type for BAT optimization algorithms.
A typical application for optimization in BAT is mode estimation (see bat_findmode),
BAT.AbstractSamplingAlgorithm — Type
abstract type BAT.AbstractSamplingAlgorithmAbstract type for BAT sampling algorithms. See bat_sample.
BAT.ConvergenceTest — Type
abstract type ConvergenceTestAbstract type for integrated autocorrelation length estimation algorithms.