Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more distproxys #83

Open
cscherrer opened this issue Mar 26, 2021 · 1 comment
Open

Add more distproxys #83

cscherrer opened this issue Mar 26, 2021 · 1 comment
Labels
good first issue Good for newcomers

Comments

@cscherrer
Copy link
Collaborator

Rather than trying to rebuild all functionality from Distributions.jl, we're first focusing on reimplementing logdensity (logpdf in Distributions), and delegating most other functions to the current Distributions implementations.

So for example, we have

distproxy(d::Normal{(:μ, :σ)}) = Dists.Normal(d.μ, d.σ)

This makes some functions in Distributions.jl available through distproxy.jl:

PROXIES = Dict(
    :Distributions => [
        :mean
        :std
        :var
        :entropy
        :cdf
        :quantile
        ],
    :MonteCarloMeasurements => [
        :Particles
    ]
)

for m in keys(PROXIES)
    for f in PROXIES[m]
        @eval begin
            import $m: $f
            export $f
            $m.$f(d::AbstractMeasure, args...) = $m.$f(MeasureTheory.distproxy(d), args...)
        end
    end
end

So for example, without ever defining cdf explicitly, we get

julia> Dists.cdf(Normal(2,5),3.1)
0.5870644226482147

julia> @which Dists.cdf(Normal(2,5),3.1)
cdf(d::AbstractMeasure, args...) in MeasureTheory at /home/chad/git/MeasureTheory.jl/src/distproxy.jl:21

We need a distproxy for every parameterization. For example, we should have something like

distproxy(d::Normal{(:μ, :logσ)}) = Dists.Normal(d.μ, exp(d.logσ))
@cscherrer cscherrer added the good first issue Good for newcomers label Mar 26, 2021
@gdalle
Copy link
Collaborator

gdalle commented Aug 21, 2021

See #145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants