Closed nignatiadis closed 4 years ago
Huh. Yeah, you're right. That's a good point.
Will do. Thanks for the good suggestions.
Done @nignatiadis
Note that a consequence is that we can add MixtureExpectation
s and IterableExpectation
s, e.g.
julia> e1 = expectation(Normal());
julia> e2 = expectation(Uniform());
julia> e3 = expectation(Gamma());
julia> E = e1 + (e2 + e3);
julia> typeof(E.expectations[2])
MixtureExpectation{Tuple{IterableExpectation{Array{Float64,1},Array{Float64,1}},IterableExpectation{Array{Float64,1},Array{Float64,1}}},Array{Float64,1}}
julia> E(x -> x) == e1(identity) + e2(identity) + e3(identity)
true
This is super cool!! Thank you a lot!
This is a follow-up to #42. I just realized that
MixtureExpectation
implements addition of expectations:So adding methods for
+(e1::Expectation, e2::Expectation)
would be both elegant from a mathematical perspective (especially since*
is already implemented) and also quite practical/useful!