Skip to content

Update Readme #54

Description

@azev77

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions