Internal API
This is the documentation of BAT's internal API. The internal API is fully accessible to users, but all aspects of it are subject to change without deprecation. Functionalities of the internal API that, over time, turn out to require user access (e.g. to support advanced use cases) will be evolved to gain a stable interface and then promoted to the public API.
Types
BAT.AbstractSampleGeneratorBAT.AnySampleableBAT.BATMeasureBAT.BATPushFwdMeasureBAT.BATPwrMeasureBAT.BATWeightedMeasureBAT.BasicMvStatisticsBAT.CholeskyPartialWhiteningBAT.CholeskyWhiteningBAT.DensitySampleMeasureBAT.ENSAutoProposalBAT.ENSBoundBAT.ENSEllipsoidBoundBAT.ENSMultiEllipsoidBoundBAT.ENSNoBoundsBAT.ENSProposalBAT.ENSRandomWalkBAT.ENSSliceBAT.ENSUniformlyBAT.FullMeasureTransformBAT.LFDensityBAT.LFDensityWithGradBAT.LogDValBAT.MCMCSampleGeneratorBAT.MeasureLikeBAT.NoWhiteningBAT.OnlineMvCovBAT.OnlineMvMeanBAT.OnlineUvMeanBAT.OnlineUvVarBAT.SampleTransformationBAT.StandardMvNormalBAT.StandardMvUniformBAT.StandardUvNormalBAT.StandardUvUniformBAT.StatisticalWhiteningBAT.UnshapeTransformationBAT.WhiteningAlgorithm
Functions and macros
BAT.argchoice_msgBAT.bg_R_2sqrBAT.checked_logdensityofBAT.drop_low_weight_samplesBAT.fft_autocorBAT.fft_autocovBAT.find_marginalmodesBAT.get_bin_centersBAT.getlikelihoodBAT.getpriorBAT.gr_RsqrBAT.is_log_zeroBAT.issymmetric_around_originBAT.log_zero_densityBAT.logvalofBAT.measure_supportBAT.repetition_to_weightsBAT.smallest_credible_intervalsBAT.sum_first_dimBAT.supports_randBAT.trunc_logpdf_ratioBAT.truncate_dist_hard
Documentation
BAT.AbstractSampleGenerator — Type
abstract type AbstractSampleGeneratorBAT-internal, not part of stable public API.
Abstract super type for sample generators.
BAT.AnySampleable — Type
BAT.AnySampleable = Union{...}Union of all types that BAT can sample from:
BAT.BasicMvStatistics — Type
BasicMvStatistics{T<:Real,W}BAT-internal, not part of stable public API.
W must either be Weights (no bias correction) or one of AnalyticWeights, FrequencyWeights or ProbabilityWeights to specify the desired bias correction method.
BAT.BATMeasure — Type
abstract type BATMeasure <:AbstractMeasureBAT-internal, not part of stable public API.
Subtypes must implement DensityInterface.logdensityof and ValueShapes.varshape.
BAT.BATPushFwdMeasure — Type
BATPushFwdMeasureBAT-internal, not part of stable public API.
BAT.BATPwrMeasure — Type
BATPwrMeasureBAT-internal, not part of stable public API.
BAT.BATWeightedMeasure — Type
struct BATWeightedMeasure <: BATMeasureBAT-internal, not part of stable public API.
BAT.CholeskyPartialWhitening — Type
struct CholeskyPartialWhitening <: WhiteningAlgorithmBAT-internal, not part of stable public API.
Whitening transformation based on a Cholesky transformation of the empirical sample covariance matrix.
Only transforms dimensions (degrees of freedom) for which the marginalized distribution asymptotically approaches zero in the positive and negative direction.
Constructors:
CholeskyPartialWhitening()
BAT.CholeskyWhitening — Type
struct CholeskyWhitening <: WhiteningAlgorithmBAT-internal, not part of stable public API.
Whitening transformation based on a Cholesky transformation of the empirical sample covariance matrix.
Constructors:
CholeskyWhitening()
BAT.DensitySampleMeasure — Type
DensitySampleMeasureBAT-internal, not part of stable public API.
BAT.ENSAutoProposal — Type
struct BAT.ENSAutoProposal <: ENSProposalExperimental feature, not part of stable public API.
Choose the proposal depending from the number of dimensions: ndims < 10: Proposals.Uniform, 10 ≤ ndims ≤ 20: Proposals.RWalk, ndims > 20: Proposals.Slice
BAT.ENSBound — Type
abstract type ENSBoundExperimental feature, not part of stable public API.
Abstract type for the bounds of the sampling region used by EllipsoidalNestedSampling.
BAT.ENSEllipsoidBound — Type
struct BAT.ENSEllipsoidBound <: ENSBoundExperimental feature, not part of stable public API.
Ellipsoid bound means that a n-dimensional ellipsoid limits the sampling volume.
BAT.ENSMultiEllipsoidBound — Type
struct BAT.ENSMultiEllipsoidBound <: ENSBoundExperimental feature, not part of stable public API.
Multi ellipsoid bound means that there are multiple elliposid in an optimal clustering are used to limit the sampling volume.
BAT.ENSNoBounds — Type
struct BAT.ENSNoBounds <: ENSBoundExperimental feature, not part of stable public API.
No bounds means that the whole volume from the unit Cube is used to find new points.
BAT.ENSProposal — Type
abstract type ENSProposalExperimental feature, not part of stable public API.
Abstract type for the algorithms to propose new live points used used by EllipsoidalNestedSampling.
BAT.ENSRandomWalk — Type
struct BAT.ENSRandomWalk <: ENSProposalExperimental feature, not part of stable public API.
New live point is proposed by using a random walk away from an existing live point.
Constructors:
ENSRandomWalk(; fields...)
Fields:
ratio::Float64: Acceptance ratio for the random walk. Default: 0.5walks::Int64: Minimum number of random walk steps. Default: 25scale::Float64: Scale of the proposal distribution. Default: 1.0
BAT.ENSSlice — Type
struct BAT.ENSSlice <: ENSProposalExperimental feature, not part of stable public API.
New live point is proposed by a serie of random slices from an existing live-point.
Constructors:
ENSSlice(; fields...)
Fields:
slices::Int64: Minimum number of slices Default: 5scale::Float64: Scale of the proposal distribution. Default: 1.0
BAT.ENSUniformly — Type
struct BAT.ENSUniformly <: ENSProposalExperimental feature, not part of stable public API.
Each point in the bounding volume has an uniform chance to be proposed as a new live point.
BAT.FullMeasureTransform — Type
struct FullMeasureTransform <: TransformAlgorithmBAT-internal, not part of stable public API.
Transform the density as a whole a given specified target space. Operations that use the gradient of the density will require to the log(abs(jacobian)) of the transformation to be auto-differentiable.
Constructors:
FullMeasureTransform()
BAT.LFDensity — Type
struct BAT.LFDensity{F}BAT-internal, not part of stable public API.
Wraps a log-density function log_f.
BAT.LFDensityWithGrad — Type
BAT.LFDensityWithGrad{F,G} <: BATDensityBAT-internal, not part of stable public API.
Constructors:
LFDensityWithGrad(logf, valgradlogf)A density defined by a function that computes it's logarithmic value at given points, as well as a function that computes both the value and the gradient.
It must be safe to execute both functions in parallel on multiple threads and processes.
BAT.LogDVal — Type
struct LogDVal{T<:Real}LogDVal is deprecated and will be removed in future major or even minor BAT versions.
BAT.MCMCSampleGenerator — Type
BAT.MCMCSampleGeneratorBAT-internal, not part of stable public API.
MCMC sample generator.
Constructors:
MCMCSampleGenerator(mc_state::AbstractVector{<:MCMCIterator})BAT.MeasureLike — Type
BAT.MeasureLike = Union{...}BAT-internal, not part of stable public API.
Union of all types that BAT will accept as a measures or convert to measures.
BAT.NoWhitening — Type
struct NoWhitening <: WhiteningAlgorithmBAT-internal, not part of stable public API.
No-op whitening transformation, leaves samples unchanged.
Constructors:
NoWhitening()
BAT.OnlineMvCov — Type
OnlineMvCov{T<:AbstractFloat,W} <: AbstractMatrix{T}BAT-internal, not part of stable public API.
Implementation based on variance calculation Algorithms of Welford and West.
W must either be Weights (no bias correction) or one of AnalyticWeights, FrequencyWeights or ProbabilityWeights to specify the desired bias correction method.
BAT.OnlineMvMean — Type
OnlineMvMean{T<:AbstractFloat} <: AbstractVector{T}BAT-internal, not part of stable public API.
Multivariate mean implemented via Kahan-Babuška-Neumaier summation.
BAT.OnlineUvMean — Type
OnlineUvMean{T<:AbstractFloat}BAT-internal, not part of stable public API.
Univariate mean implemented via Kahan-Babuška-Neumaier summation.
BAT.OnlineUvVar — Type
OnlineUvVar{T<:AbstractFloat,W}BAT-internal, not part of stable public API.
Implementation based on variance calculation Algorithms of Welford and West.
W must either be Weights (no bias correction) or one of AnalyticWeights, FrequencyWeights or ProbabilityWeights to specify the desired bias correction method.
BAT.SampleTransformation — Type
struct SampleTransformation <: TransformAlgorithmBAT-internal, not part of stable public API.
BAT.StandardMvNormal — Type
StandardMvNormal{T<:Real} <: Distributions.AbstractMvNormalA standard n-dimensional multivariate normal distribution with it's mean at the origin and an identity covariance matrix.
Constructor:
StandardMvNormal(n::Integer)
StandardMvNormal{T<:Real}(n::Integer)BAT.StandardMvUniform — Type
StandardMvUniform{T<:Real} <: Distributions.Distribution{Multivariate,Continuous}A standard n-dimensional multivariate uniform distribution, from zero to one in each dimension.
Constructor:
StandardMvUniform(n::Integer)
StandardMvUniform{T<:Real}(n::Integer)BAT.StandardUvNormal — Type
StandardUvNormal{T<:Real} <: Distributions.Distribution{Univariate,Continuous}A standard normal distribution with a mean of zero and a variance of one.
Constructor:
StandardUvNormal()
StandardUvNormal{T<:Real}()BAT.StandardUvUniform — Type
StandardUvUniform{T<:Real} <: Distributions.Distribution{Univariate,Continuous}A standard uniform distribution between zero and one.
Constructor:
StandardUvUniform()
StandardUvUniform{T<:Real}()BAT.StatisticalWhitening — Type
struct StatisticalWhitening <: WhiteningAlgorithmBAT-internal, not part of stable public API.
Whitening transformation based statistical whitening. CholeskyPartialWhitening
Constructors:
StatisticalWhitening()
BAT.UnshapeTransformation — Type
struct UnshapeTransformation <: TransformAlgorithmBAT-internal, not part of stable public API.
BAT.WhiteningAlgorithm — Type
abstract type WhiteningAlgorithmBAT-internal, not part of stable public API.
Abstract type for sample whitening algorithms.
BAT.logvalof — Function
logvalof(r::NamedTuple{(...,:log,...)})::Real
logvalof(r::LogDVal)::RealBAT-internal, not part of stable public API.
BAT.fft_autocor — Function
fft_autocor(v::AbstractVector{<:Real})
fft_autocor(v::AbstractVectorOfSimilarVectors{<:Real})BAT-internal, not part of stable public API.
Compute the autocorrelation function (ACF) of variate series v, separately for each degree of freedom.
Uses FFT, in contract to StatsBase.autocor.
BAT.fft_autocov — Function
fft_autocov(v::AbstractVector{<:Real})
fft_autocov(v::AbstractVectorOfSimilarVectors{<:Real})BAT-internal, not part of stable public API.
Compute the autocovariance of of variate series v, separately for each degree of freedom.
Uses FFT, in contract to StatsBase.autocov.
BAT.argchoice_msg — Function
argchoice_msg(f::Base.Callable, argname::Val, x)BAT-internal, not part of stable public API.
Generates an information message regarding the choice of value x for argument argname of function f.
The value x will often be the result of bat_default.
BAT.bg_R_2sqr — Function
bg_R_2sqr(stats::AbstractVector{<:MCMCBasicStats}; corrected::Bool = false)
bg_R_2sqr(samples::AbstractVector{<:DensitySampleVector}; corrected::Bool = false)BAT-internal, not part of stable public API.
Brooks-Gelman R_2^2 for all DOF. If normality is assumed, 'corrected' should be set to true to account for the sampling variability.
BAT.checked_logdensityof — Function
checked_logdensityof(measure::AbstractMeasure, v::Any, T::Type{<:Real})BAT-internal, not part of stable public API.
Evaluates the measure's log-density value via DensityInterface.logdensityof and performs additional checks.
Throws a BAT.EvalException on any of these conditions:
- The variate shape of
measure(if known) does not match the shape ofv. - The return value of
DensityInterface.logdensityofisNaN. - The return value of
DensityInterface.logdensityofis an equivalent of positive infinity.
BAT.drop_low_weight_samples — Function
drop_low_weight_samples(
samples::DensitySampleVector,
fraction::Real = 10^-4
)BAT-internal, not part of stable public API.
Drop fraction of the total probability mass from samples to filter out the samples with the lowest weight.
BAT.find_marginalmodes — Function
find_marginalmodes(marg::MarginalDist)BAT-internal, not part of stable public API.
Find the modes of a MarginalDist. Returns a vector of the bin-centers of the bin(s) with the heighest weight.
BAT.get_bin_centers — Function
get_bin_centers(marg::MarginalDist)BAT-internal, not part of stable public API.
Returns a vector of the bin-centers.
BAT.getlikelihood — Function
getlikelihood(posterior::AbstractPosteriorMeasure)::BATDenstiyBAT-internal, not part of stable public API.
The likelihood density of posterior. The likelihood may or may not be normalized.
BAT.getprior — Function
getprior(posterior::AbstractPosteriorMeasure)::BATMeasureBAT-internal, not part of stable public API.
The prior density of posterior. The prior may or may not be normalized.
BAT.gr_Rsqr — Function
gr_Rsqr(stats::AbstractVector{<:MCMCBasicStats})
gr_Rsqr(samples::AbstractVector{<:DensitySampleVector})BAT-internal, not part of stable public API.
Gelman-Rubin $$R^2$$ for all DOF.
BAT.is_log_zero — Function
BAT.is_log_zero(x::Real, T::Type = typeof(x)}BAT-internal, not part of stable public API.
Check if x is an equivalent of log of zero, resp. negative infinity, in respect to type T.
BAT.issymmetric_around_origin — Function
issymmetric_around_origin(d::Distribution)BAT-internal, not part of stable public API.
Returns true (resp. false) if the Distribution is symmetric (resp. non-symmetric) around the origin.
BAT.log_zero_density — Function
BAT.log_zero_density(T::Type{<:Real})log-density value to assume for regions of implicit zero density, e.g. outside of variate/parameter bounds/support.
Returns an equivalent of negative infinity.
BAT.repetition_to_weights — Function
repetition_to_weights(v::AbstractVector)BAT-internal, not part of stable public API.
Drop (subsequently) repeated samples by adding weights.
BAT.smallest_credible_intervals — Function
smallest_credible_intervals(
X::AbstractVector{<:Real}, W::AbstractWeights = UnitWeights(...);
nsigma_equivalent::Integer = 1
)BAT-internal, not part of stable public API.
Find smalles credible intervals with nsigma_equivalent of 1, 2 or 3 (containing 68.27%, 90.00%, 95.45% or 99.73% of the total probability mass).
smallest_credible_intervals(smpl::DensitySampleVector{<:AbstractVector{<:Real}}; kwargs...)BAT.sum_first_dim — Function
@propagate_inbounds sum_first_dim(A::AbstractArray, j::Integer, ks::Integer...)BAT-internal, not part of stable public API.
Calculate the equivalent of sum(A[:, j, ks...]).
@propagate_inbounds sum_first_dim(A::AbstractArray)BAT-internal, not part of stable public API.
If A is a vector, return sum(A), else sum(A, 1)[:].
BAT.supports_rand — Function
supports_rand(m)BAT-internal, not part of stable public API.
Convert a measure-like object m supports rand.
BAT.trunc_logpdf_ratio — Function
BAT.trunc_logpdf_ratio(orig_dist::Distribution{TP}, trunc_dist::Distribution{TP})::AbstractFloatBAT-internal, not part of stable public API.
Computes the log-ratio between the amplitude of the PDF of a truncated distribution and the original (untruncted) distribution, within the support of the truncated one.
The PDF of both distributions must have the same shape within the support of trunc_dist and may only differ in amplitude.
Mainly used to implement BAT.truncate_batmeasure, in conjunction with BAT.truncate_dist_hard.
BAT.truncate_dist_hard — Function
BAT.truncate_dist_hard(dist::Distribution{Univariate}, bounds::Interval)::Distribution{Univariate}
BAT.truncate_dist_hard(dist::Distribution{Multivariate}, bounds::AbstractArray{<:Interval})::Distribution{Multivariate}BAT-internal, not part of stable public API.
Generalized variant of Distributions.truncated - also handles multivariate distributions and operates on a best-effort basis: If distributions cannot be truncated, may return the original distribution.
Returns a NamedTuple
(dist = trunc_dist, logweight = logweight)with the truncated distribution and the log-PDF amplitude difference to the original (see BAT.trunc_logpdf_ratio).
Mainly used to implement BAT.truncate_batmeasure.
BAT.measure_support — Function
measure_support(measure::AbstractMeasure)BAT-internal, not part of stable public API.
Get the parameter bounds of measure. May return a IntervalsSets.Domain or BAT.UnknownDomain