Small wrapper for quadrature code and Distributions.jl
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.codecov.yml
.gitignore
.travis.yml
LICENSE.md
Manifest.toml
Project.toml
README.md
REQUIRE
appveyor.yml

README.md

DistQuads

Build Status

Coverage Status

codecov.io

What

Evaluating the expected value of functions of random variables requires numerical integration. There are many ways to do this, but a very popular approach is to transform the integral evaluation into a weighed sum of function evaluations at N values, often called nodes, useing so-called Gaussian quadrature.

This package builds on top of the Distributions.jl package, and it provides a simple interface to generate Guassian quadrature weights and nodes for numerical integration as explained above.

julia> using Distributions, DistQuads

julia> bd = Beta(1.4, 5.4)
Distributions.Beta{Float64}=1.4, β=5.4)

julia> dq = DistQuad(bd)
DistQuads.DistQuad([0.00185197,0.00773162,0.017613,0.0314164,0.0490303,0.0703119,0.095089,0.123161,0.1543,0.1882550.740476,0.779219,0.815718,0.849678,0.880826,0.90891,0.933707,0.955022,0.972705,0.986694],[0.00387997,0.013685,0.0273551,0.0429761,0.0586422,0.0726105,0.0834732,0.0902888,0.0926473,0.09066050.00117028,0.000555584,0.000239261,9.17104e-5,3.04716e-5,8.44413e-6,1.83878e-6,2.84652e-7,2.58301e-8,8.47448e-10],Distributions.Beta{Float64}=1.4, β=5.4))

julia> mean(dq)
0.20588235294117635

julia> mean(bd)
0.20588235294117643

julia> var(dq)
0.020960873036997594

julia> var(bd)
0.020960873036997597