-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
types.jl
56 lines (46 loc) · 1.98 KB
/
types.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Types for quadrature algorithms.
"""
Abstract type for quadrature algorithms without user-defined nodes (e.g., Gaussian quadrature.)
"""
abstract type QuadratureAlgorithm end
"""
Abstract type for quadrature algorithms with user-defined nodes (e.g., trapezoidal integration).
"""
abstract type ExplicitQuadratureAlgorithm end
# Concrete types for quadrature algorithms.
"""
Gaussian quadrature. See specific methods for what precise algorithm is used (e.g., Gauss-Legendre, Gauss-Hermite, etc.)
"""
struct Gaussian <: QuadratureAlgorithm end # Distribution-family specific quadrature.
"""
A custom quadrature scheme written by Spencer Lyon as part of the QuantEcon.jl library. Used with permission.
For detailed information, see: https://github.com/QuantEcon/QuantEcon.jl/blob/be0a32ec17d1f5b04ed8f2e52604c70c69f416b2/src/quad.jl#L918.
"""
struct QuantileRange <: QuadratureAlgorithm end
"""
A dot product of a (finite) PDF vector and a finite set of transformed nodes.
"""
struct FiniteDiscrete <: ExplicitQuadratureAlgorithm end # Dot-product basically.
"""
Trapezoidal integration.
"""
struct Trapezoidal <: ExplicitQuadratureAlgorithm end # For iterable expectations.
# Abstract types for expectations.
"""
Abstract type for all expectations.
"""
abstract type Expectation end # Supports E(f)
# Concrete types for expectations.
#= For an example of using abstract types named in this way, see: https://github.com/JuliaStats/Distributions.jl/blob/2d98eb6f31e9a92cce416e7391a84cff9bba7292/src/truncate.jl#L1-L10. We define a family of Truncated{blahblahblah} types parametrically, but use the abstract Truncated as a supertype for all Truncated distributions.
=#
"""
Expectations which are paramterized by a vector of nodes (e.g., a discretized support) and corresponding quadrature weights.
"""
struct IterableExpectation{NT, WT} <: Expectation # Supports E(f), nodes, weights, *
nodes::NT
weights::WT
end
struct MixtureExpectation{ET, WT} <: Expectation
expectations::ET
mixtureweights::WT
end