Skip to content

Commit 31693ea

Browse files
committed
add Half and decompose
1 parent 48173ba commit 31693ea

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/MeasureBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Methods for computing density relative to other measures will be
3030
"""
3131
function logdensity end
3232

33-
33+
include("combinators/half.jl")
3434
include("exp.jl")
3535
include("domains.jl")
3636
include("utils.jl")

src/combinators/half.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export Half
2+
3+
struct Half{M} <: AbstractMeasure
4+
μ::M
5+
end

src/macros.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,11 @@ function _half(__module__, ex)
269269
function Base.rand(rng::AbstractRNG, T::Type, μ::$halfdist)
270270
return abs(rand(rng, T, unhalf(μ)))
271271
end
272-
272+
273+
function decompose::$halfdist)
274+
return Half($dist)
275+
end
276+
273277
(::$halfdist ::Lebesgue{ℝ₊}) = true
274278
end
275279
end

0 commit comments

Comments
 (0)