Skip to content

QuantEcon/Expectations.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travis status Build 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))

About

Expectation operators for Distributions.jl objects

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors 9