Moments and expectation

Moment

Given a measure $\mu$ and a monomial $m$, the moment $m$ of the measure is defined by the expectation $\mathbb{E}_\mu[m]$. Given a monomial and a value for the moment, a moment can be created using the moment function

The moment function returns an AbstractMoment which is a subtype of AbstractMomentLike. An AbstractMomentLike is a type that can act like an AbstractMoment (it is similar to MultivariatePolynomials' AbstractMonomialLike, AbstractTermLike and AbstractPolynomialLike), that is, it implements the following two functions

Measure

Given a monomials and a values for the moments, a "moment vector" can be created using the moment_vector function

MultivariateMoments.moment_vector — Function
moment_vector(values::AbstractVector{T}, monos::AbstractVector{<:AbstractMonomial}; rtol=Base.rtoldefault(T), atol=zero(T))

Creates a measure with moments moment(values[i], monos[i]) for each i. An error is thrown if there exists i and j such that monos[i] == monos[j] but !isapprox(values[i], values[j]; rtol=rtol, atol=atol).

source
moment_vector(values::AbstractVector, basis::MB.QuotientBasis)

Return the moments of the elements of basis.basis given the values values of the linear functional on the elements of basis. As the coefficients in basis are basis.matrix times the coefficients in basis.basis, the moments are obtained with the adjoint map transpose(basis.matrix) * values.

source

The moment_vector function returns an AbstractMeasure which is a subtype of AbstractMeasureLike. Note that it does not actually compute the probability density function of a measure having these moments, it simply stores a vector of moments belonging to a hypothetical measure. However, it acts like a measure when taking its scalar product with a polynomial.

An AbstractMeasureLike is a type that can act like an AbstractMeasure, that is, it implements the following two functions

MultivariatePolynomials.variables — Method
variables(μ::MomentVector)

Returns the variables of μ in decreasing order. Just like in MultivariatePolynomials, it could contain variables of zero degree in every monomial.

source

The moments of the dirac measure for a vector of monomials can be obtained by the dirac function

MultivariateMoments.dirac — Function
dirac(X::AbstractVector{<:AbstractMoment}, s::AbstractSubstitution...)

Creates the dirac measure by evaluating the moments of X using s.

Examples

Calling dirac([x*y, x*y^2], x=>3, y=>2) should the measure with moment x*y of value 6 and moment x*y^2 of value 12.

source

Expectation

The expectation of polynomial with respect to a measure can be computed either using MultivariateMoments.expectation or using the Base.dot scalar product.

MultivariateMoments.expectation — Function
MultivariateMoments.expectation(μ::AbstractMeasureLike, p::AbstractPolynomialLike)
MultivariateMoments.expectation(p::AbstractPolynomialLike, μ::AbstractMeasureLike)

Computes the expectation $\mathbb{E}_{\mu}[p]$.

source

Quotient

The moments of a measure supported on an algebraic set are only determined modulo the ideal of the set. The quotient of the span of monomials modulo this ideal is computed by quotient_basis.

MultivariateMoments.quotient_basis — Function
quotient_basis(basis::MB.SubBasis{MB.Monomial}, domain)

Return a MultivariateBases.QuotientBasis representing the quotient of the span of basis modulo the ideal of domain, which is either an algebraic set, a polynomial ideal or a SemialgebraicSets.TruncatedIdeal. The matrix is a sparse matrix with float of the coefficient type of domain as element type.

If a Gröbner basis of the ideal is known, the matrix gives the remainders of the elements of basis modulo the Gröbner basis. For a truncated ideal, the polynomials whose coefficients are in the kernel of the matrix are the polynomials in the row space of the Macaulay matrix of its degree. If the Gröbner basis of domain is not known, it is computed, which may be expensive. To avoid this, truncate domain with SemialgebraicSets.truncated.

source