Skip to content
Expectation operators for Distributions.jl objects
Branch: master
Clone or download
Latest commit 87a8e9e Mar 21, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Update Jan 30, 2019
src include check from #25 Dec 3, 2018
test alg is not a kwarg Mar 21, 2019
.codecov.yml Expectations.jl generated files. Jul 10, 2018
.gitignore documenter first pass Jul 20, 2018
.travis.yml Add Julia 1.1 to Travis Jan 30, 2019 update Mar 11, 2019 Update Nov 13, 2018
REQUIRE remove reexport, _expectations export Aug 10, 2018
appveyor.yml Expectations.jl generated files. Jul 10, 2018

Travis status codecov


Installation (v1.0 and up):

pkg> add Expectations

This is a package designed to simplify the process of taking expectations of functions of random variables.

Random Variables

The underlying distributions are objects from Distributions.jl (currently <:UnivariateDistribution).

Quadrature Algorithms

We support different types of Gaussian quadrature (Gauss-Hermite, Gauss-Legendre, Gauss-Laguerre, etc.) based on the distribution, as well as some methods with user-defined nodes (e.g., trapezoidal integration).

Expectation Operator

The key object is the expectation function, which returns an operator:

dist = Normal()
E = expectation(dist)
E(x -> x)

For convenience, the operator can be applied directly to a function instead of being cached,

expectation(x->x^2, dist)

As a linear operator on vectors using the nodes of the distribution

dist = Normal()
E = expectation(dist)
x = nodes(E)
f(x) = x^2
E * f.(x) == dot(f.(x), weights(E))
You can’t perform that action at this time.