Expectations.jl icon indicating copy to clipboard operation
Expectations.jl copied to clipboard

Update Readme

Open azev77 opened this issue 5 years ago • 1 comments

Add using Expectations etc. General syntax: expectation(x->f(x), Distribution(θ))

using Expectations, Distributions;
E=expectation;
const μ=0.0; const σ=1.0;
E(x->x, Normal(μ,σ))
E(x->exp(x), Normal(μ,σ))
exp(μ+ (σ^2)/2.)
E(x->x^2, Normal(μ,σ))
E(x->x^2+exp(x), Normal(μ,σ))
#
D = [Uniform(), Normal(), Gamma()];
d = MixtureModel(D);
E.(x->x, D)
E(x->x, d)     #expectation of a mixture
( E(x->x,D[1]) + E(x->x,D[2]) + E(x->x,D[3]) )/3
#
E(x->x^2, d) #expectation of a transformation of a mixture

# truncated dist
d=truncated(LogNormal(μ,σ),0.0,5.4)
E(x->x, d)
E(x->x^2, d)
# truncated mixture
d=truncated(MixtureModel(D),0.0,5.4)
E(x->x, d)
E(x->x^2, d)

If you can agree, I can submit PR.

azev77 avatar Oct 12 '20 18:10 azev77

Hi @azev77, sure, I think the README should always be copy/pastable and detailed.

Thanks for your interest and looking forward to the PR.

arnavs avatar Oct 12 '20 20:10 arnavs