Algebra common utilities
diageye
ReactiveMP.diageye
— Functiondiageye(::Type{T}, n::Int)
An alias for the Matrix{T}(I, n, n)
. Returns a matrix of size n x n
with ones (of type T
) on the diagonal and zeros everywhere else.
diageye(n::Int)
An alias for the Matrix{Float64}(I, n, n)
. Returns a matrix of size n x n
with ones (of type Float64
) on the diagonal and zeros everywhere else.
ReactiveMP.CompanionMatrix
— TypeCompanionMatrix
Represents a matrix of the following structure:
θ1 θ2 θ3 ... θn-1 θn 1 0 0 ... 0 0 0 1 0 ... 0 0 . . . ... . . . . . ... . . 0 0 0 ... 0 0 0 0 0 ... 1 0
ReactiveMP.PermutationMatrix
— TypePermutationMatrix(ind::Array{T})
creates a permutation matrix with ones at coordinates (k, ind[k]) for k = 1:length(ind)
.
A permutation matrix represents a matrix containing only zeros and ones, which basically permutes the vector or matrix it is multiplied with. These matrices A are constrained by:
\[ A_{ij} = \{0, 1\}\\ ∑_{i} A_{ij} = 1\\ ∑_{j} A_{ij} = 1\]
An example is the 3-dimensional permutation matrix
\[A = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0 \end{bmatrix}\]
ReactiveMP.StandardBasisVector
— TypeStandardBasisVector{T, len, ind}(scale::T)
StandardBasisVector
creates a standard Cartesian basis vector of zeros of length len
with a single element scale
at index ind
.
An example is the 3-dimensional standard basis vector for the first dimension
\[e = \begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix}\]
Which can be constructed by calling e = StandardBasisVector(3, 1, 1)
ReactiveMP.GammaShapeLikelihood
— Typeν(x) ∝ exp(p*β*x - p*logГ(x)) ≡ exp(γ*x - p*logГ(x))
ReactiveMP.ImportanceSamplingApproximation
— TypeImportanceSamplingApproximation
This structure stores all information needed to perform an importance sampling procedure and provides convenient functions to generate samples and weights to approximate expectations
Fields
rng
: random number generator objectsnsamples
: number of samples generated by default
ReactiveMP.mul_inplace!
— Functionmul_inplace!(alpha, A)
Returns alpha * A
, modifying and reusing A
storage if possible.
See also: negate_inplace!
ReactiveMP.negate_inplace!
— FunctionReactiveMP.mul_trace
— Functionmul_trace(A, B)
Computes tr(A * B) without allocating A * B.
ReactiveMP.rank1update
— Functionrank1update(A, x)
rank1update(A, x, y)
Helper function for A + x * y'. Uses optimised BLAS version for AbstractFloats and fallbacks to a generic implementation in case of differentiation
ReactiveMP.v_a_vT
— Functionv_a_vT(v, a)
Computes vav^T efficiently.
ReactiveMP.powerset
— Functionpowerset(iterator)
Computes the set of all possible sets of the iterator
.
ReactiveMP.besselmod
— FunctionModified-bessel function of second kind
mx, vx : mean and variance of the random variable x my, vy : mean and variance of the random variable y rho : correlation coefficient