JuliaMath / JuliaMath/MeasureTheory.jl

Move ConditionalMeasure to MeasureBase

Open
#186 0 comments 0 reactions 1 assignee Claimed by @cscherrer View on GitHub
Dominant language
Julia
Stars
401
Forks
31
PR merge metrics
No merged PRs in 30d

Description

Currently in [conditional.jl](https://github.com/cscherrer/MeasureTheory.jl/blob/f4f83851f0abcf554a4b0403d1e29943092547a8/src/combinators/conditional.jl) we have
```julia
using NestedTuples: lazymerge

struct ConditionalMeasure{M,C} <: AbstractMeasure
parent::M
constraint::C
end

Base.:|(μ::AbstractMeasure, constraint) = ConditionalMeasure(μ, constraint)

@inline function logdensity_def(cm::ConditionalMeasure, x)
logdensity_def(cm.parent, lazymerge(cm.constraint, x))
end

@inline basemeasure(cm::ConditionalMeasure) = basemeasure(cm.parent) | cm.constraint
```

This really belongs as part of the interface, so it should be moved to MeasureBase. Also, the `constraint` could be extended beyond named tuples, so the `logdensity_def` method should really be
```julia
@inline function logdensity_def(cm::ConditionalMeasure{M,C}, x) where {M,C<:NamedTuple}
logdensity_def(cm.parent, lazymerge(cm.constraint, x))
end
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.