MeasureTheory.jl
MeasureTheory.jl copied to clipboard
Add more `distproxy`s
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σ))
See #145