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 "measure" can be created using the measure function

MultivariateMoments.measureFunction
measure(a::AbstractVector{T}, X::AbstractVector{<:AbstractMonomial}; rtol=Base.rtoldefault(T), atol=zero(T))

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

source

The measure 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.variablesMethod
variables(μ::AbstractMeasureLike)

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.diracFunction
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.expectationFunction
MultivariateMoments.expectation(μ::AbstractMeasureLike, p::AbstractPolynomialLike)
MultivariateMoments.expectation(p::AbstractPolynomialLike, μ::AbstractMeasureLike)

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

source