BayesBase.ClosedProdType
ClosedProd

ClosedProd is one of the strategies for prod function. For example, if both inputs are of type Distribution, then ClosedProd would fallback to PreserveTypeProd(Distribution).

See also: prod, PreserveTypeProd, GenericProd

BayesBase.ContingencyType
Contingency(P, renormalize = Val(true))

The contingency distribution is a multivariate generalization of the categorical distribution. As a bivariate distribution, the contingency distribution defines the joint probability over two unit vectors v1 and v2. The parameter P encodes a contingency matrix that specifies the probability of co-occurrence.

v1 ∈ {0, 1}^d1 where Σ_j v1_j = 1
v2 ∈ {0, 1}^d2 where Σ_k v2_k = 1

P ∈ [0, 1]^{d1 × d2}, where Σ_jk P_jk = 1

f(v1, v2, P) = Contingency(out1, out2 | P) = Π_jk P_jk^{v1_j * v2_k}

A Contingency distribution over more than two variables requires higher-order tensors as parameters; these are not implemented in ReactiveMP.

Arguments:

  • P, required, contingency matrix
  • renormalize, optional, supports either Val(true) or Val(false), specifies whether matrix P must be automatically renormalized. Does not modify the original P and allocates a new one for the renormalized version. If set to false the contingency matrix P must be normalized by hand, otherwise the result of related calculations might be wrong
BayesBase.ContinuousMultivariateLogPdfType
ContinuousMultivariateLogPdf{ D <: DomainSets.Domain, F } <: AbstractContinuousGenericLogPdf

Generic continuous multivariate distribution in a form of domain specification and logpdf function. Can be used in cases where no known analytical distribution available.

Arguments

  • domain: multidimensional domain specification from DomainSets.jl package. Use BayesBase.UnspecifiedDomain() to bypass domain checks.
  • logpdf: callable object that accepts an AbstractVector as an input and represents the logdensity. Can be un-normalised.
BayesBase.ContinuousUnivariateLogPdfType
ContinuousUnivariateLogPdf{ D <: DomainSets.Domain, F } <: AbstractContinuousGenericLogPdf

Generic continuous univariate distribution in a form of domain specification and logpdf function. Can be used in cases where no known analytical distribution available.

Arguments

  • domain: domain specificatiom from DomainSets.jl package, by default the domain is set to DomainSets.FullSpace(). Use BayesBase.UnspecifiedDomain() to bypass domain checks.
  • logpdf: callable object that represents the logdensity. Can be un-normalised.
BayesBase.CountingRealType
CountingReal

CountingReal implements a real "number" that counts 'infinities' in a separate field. See also BayesBase.Infinity and BayesBase.MinusInfinity.

Arguments

  • value::T: value of type <: Real
  • infinities::Int: number of added/subtracted infinities
julia> r = BayesBase.CountingReal(0.0, 0)
CountingReal{Float64}(0.0, 0)

julia> float(r)
0.0

julia> r = r + BayesBase.Infinity(Float64)
CountingReal{Float64}(0.0, 1)

julia> float(r)
Inf

julia> r = r + BayesBase.MinusInfinity(Float64)
CountingReal{Float64}(0.0, 0)

julia> float(r)
0.0
BayesBase.FactorizedJointType
FactorizedJoint(components)

FactorizedJoint represents a joint distribution of independent random variables. Use component() function or square-brackets indexing to access the marginal distribution for individual variables. Use components() function to get a tuple of multipliers.

BayesBase.GenericProdType
GenericProd

GenericProd is one of the strategies for prod function. This strategy does always produces a result, even if the closed form product is not availble, in which case simply returns the ProductOf object. GenericProd sometimes fallbacks to the default_prod_rule which it may or may not use under some circumstances. For example if the default_prod_rule is ClosedProd - GenericProd will try to optimize the tree with analytical closed solutions (if possible).

See also: prod, ProductOf, ClosedProd, PreserveTypeProd, default_prod_rule

BayesBase.InplaceLogpdfType

InplaceLogpdf(logpdf!)

Wraps a logpdf! function in a type that can later on be used for dispatch. The sole purpose of this wrapper type is to allow for in-place logpdf operation on a batch of samples. Accepts a function logpdf! that takes two arguments: out and sample and writes the logpdf of the sample to the out array. A regular logpdf function can be converted to logpdf! by using convert(InplaceLogpdf, logpdf).

julia> using Distributions, BayesBase

julia> d = Beta(2, 3);

julia> inplace = convert(BayesBase.InplaceLogpdf, (sample) -> logpdf(d, sample));

julia> out = zeros(9);

julia> inplace(out, 0.1:0.1:0.9)
9-element Vector{Float64}:
 -0.028399474521697776
  0.42918163472548043
  0.5675839575845996
  0.5469646703818638
  0.4054651081081646
  0.14149956227369964
 -0.2797139028026039
 -0.9571127263944104
 -2.2256240518579173
julia> using Distributions, BayesBase

julia> d = Beta(2, 3);

julia> inplace = BayesBase.InplaceLogpdf((out, sample) -> logpdf!(out, d, sample));

julia> out = zeros(9);

julia> inplace(out, 0.1:0.1:0.9)
9-element Vector{Float64}:
 -0.028399474521697776
  0.42918163472548043
  0.5675839575845996
  0.5469646703818638
  0.4054651081081646
  0.14149956227369964
 -0.2797139028026039
 -0.9571127263944104
 -2.2256240518579173
BayesBase.LinearizedProductOfType
LinearizedProductOf

An efficient linearized implementation of product of multiple distributions. This structure prevents ProductOf tree from growing too much in case of identical objects. This trick significantly reduces Julia compilation times when closed product rules are not available but distributions are of the same type. Essentially this structure linearizes leaves of the ProductOf tree in case if it sees objects of the same type (via dispatch).

See also: ProductOf, [GenericProd]

BayesBase.PointMassType
PointMass(point)

A PointMass structure represents a delta distribution, a discrete probability distribution where all probability mass is concentrated at a single point. This point is specified by the provided point.

BayesBase.ProductOfType
ProductOf

A generic structure representing a product of two distributions. Can be viewed as a tuple of (left, right). Does not check nor supports neither variate forms during the creation stage. Uses the fuse_support function to fuse supports of two different distributions.

This object does not define any statistical properties (such as mean or var etc) and cannot be used as a distribution explicitly. Instead, it must be further approximated as a member of some other distribution.

See also: prod, GenericProd, fuse_supports

BayesBase.SampleListType
SampleList

Generic distribution represented as a list of weighted samples.

Arguments

  • samples::S
  • weights::W: optional, equivalent to fill(1 / N, N) by default, where N is the length of samples container
BayesBase.TerminalProdArgumentType
TerminalProdArgument(argument)

TerminalProdArgument is a specialized wrapper structure. When used as an argument to the prod function, it returns itself without considering any product strategy and does not perform any safety checks (e.g. variate_form or support). Attempting to calculate the product of two instances of TerminalProdArgument will raise an error. Use .argument field to get the underlying wrapped argument.

Base.prodMethod
prod(strategy, left, right)

prod function is used to find a product of two probability distributions (or any other objects) over same variable (e.g. 𝓝(x|μ1, σ1) × 𝓝(x|μ2, σ2)). There are multiple strategies for prod function, e.g. ClosedProd, GenericProd or PreserveTypeProd.

See also: default_prod_rule, ClosedProd, PreserveTypeProd, GenericProd

BayesBase.clamplogMethod
clamplog(x)

Same as log but clamps the input argument x to be in the range tiny <= x <= typemax(x) such that log(0) does not explode.

BayesBase.deep_eltypeFunction
deep_eltype(T)

Returns:

  • deep_eltype of T if T is an AbstractArray container
  • T otherwise
julia> deep_eltype(Float64)
Float64

julia> deep_eltype(Vector{Float64})
Float64

julia> deep_eltype(Vector{Matrix{Vector{Float64}}})
Float64
BayesBase.fuse_supportsMethod
fuse_supports(left, right)

Fuses supports left and right. By default, checks that the inputs are identical and throws an error otherwise. Can implement specific fusions for specific supports.

BayesBase.isequal_typeofMethod
isequal_typeof(left, right)

Alias for typeof(left) === typeof(right), but can be specialized.

BayesBase.logmvbetaMethod
logmvbeta(x)

Uses the numerically stable algorithm to compute the logarithm of the multivariate beta distribution over with the parameter vector x.

BayesBase.logpdf_optimizedMethod
logpdf_optimized(d)

Returns a version of d specifically optimized to call logpdf(d, x). By default returns the same d, but can be specialized.

BayesBase.logpdf_sampling_optimizedMethod
logpdf_sampling_optimized(d)

logpdf_sample_optimized function takes as an input a distribution d and returns corresponding optimized two versions for taking logpdf() and sampling with rand! respectively. Alias for (logpdf_optimized(d), sampling_optimized(d)), but can be specialized.

BayesBase.mcov!Method
mcov!(Z, X::AbstractMatrix, Y::AbstractMatrix; tmp1 = zeros(eltype(Z), size(X, 2)), tmp2 = zeros(eltype(Z), size(Y, 2)), tmp3 = similar(X), tmp4 = similar(Y))

Same as Statistics.cov(X, Y), but does not allocate the result. Instead uses a buffer Z to store the result in. Additionally, it allows for passing temporary buffers tmp1, tmp2, tmp3, tmp4 to avoid any allocations. Always computes corrected = true covariance matrix.

BayesBase.probvecFunction
probvec(d)

Returns the probability vector of the given distribution.

BayesBase.promote_variate_typeFunction
promote_variate_type(::Type{ <: VariateForm }, distribution_type)

Promotes (if possible) a distribution_type to be of the specified variate form.

BayesBase.promote_variate_typeMethod
promote_variate_type(::Type{D}, distribution_type) where { D <: Distribution }

Promotes (if possible) a distribution_type to be of the same variate form as D.

BayesBase.resolve_prod_strategyMethod
resolve_prod_strategy(left, right)

Given two strategies, this function returns the one with higher priority, if possible.

BayesBase.sampling_optimizedMethod
sampling_optimized(d)

Returns a version of d specifically optimized to call rand and rand!. By default returns the same d, but can be specialized.

BayesBase.vagueFunction
vague(distribution_type, [ dims... ])

Returns uninformative probability distribution of the given type.

BayesBase.weightedmeanMethod
weightedmean(d)

Returns the weighted mean of the given distribution. Alias to invcov(d) * mean(d), but can be specialized