Expectation operators for Distributions.jl objects
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
src
test
.codecov.yml
.gitignore
.travis.yml
LICENSE.md
README.md
REQUIRE
appveyor.yml

README.md

Travis status codecov

Expectations

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))