From 5c4cf60fbddbbff2b35377fa2173fd9ada1ce991 Mon Sep 17 00:00:00 2001 From: agerlach <599421+agerlach@users.noreply.github.com> Date: Tue, 6 Sep 2022 15:24:26 +0000 Subject: [PATCH 1/2] fix dispatch for 4 argument --- src/distribution_utils.jl | 2 +- test/interface.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/distribution_utils.jl b/src/distribution_utils.jl index e1b4921..960324f 100644 --- a/src/distribution_utils.jl +++ b/src/distribution_utils.jl @@ -12,7 +12,7 @@ struct GenericDistribution{TF, TRF, TLB, TUB} ub::TUB end -function GenericDistribution(d, ds...) +function GenericDistribution(d::Distributions.Sampleable, ds...) dists = (d, ds...) pdf_func(x) = exp(sum(logpdf(f, y) for (f, y) in zip(dists, x))) rand_func() = [rand(d) for d in dists] diff --git a/test/interface.jl b/test/interface.jl index c25541f..a628bdf 100644 --- a/test/interface.jl +++ b/test/interface.jl @@ -13,7 +13,7 @@ function (sm::SystemMap{DT})(u0, p) where {DT} end @testset "GenericDistribution" begin - dists = (Uniform(1, 2), Uniform(3, 4), Normal(0, 1)) + dists = (Uniform(1, 2), Uniform(3, 4), Normal(0, 1), Truncated(Normal(0, 1), -3, 3)) x = [mean(d) for d in dists] pdf_f = let dists = dists From 20aa705cfa8afd029b9e3ec8a245f588608dda05 Mon Sep 17 00:00:00 2001 From: agerlach <599421+agerlach@users.noreply.github.com> Date: Tue, 6 Sep 2022 11:46:17 -0400 Subject: [PATCH 2/2] preferred truncated form --- test/interface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/interface.jl b/test/interface.jl index a628bdf..f2954bf 100644 --- a/test/interface.jl +++ b/test/interface.jl @@ -13,7 +13,7 @@ function (sm::SystemMap{DT})(u0, p) where {DT} end @testset "GenericDistribution" begin - dists = (Uniform(1, 2), Uniform(3, 4), Normal(0, 1), Truncated(Normal(0, 1), -3, 3)) + dists = (Uniform(1, 2), Uniform(3, 4), Normal(0, 1), truncated(Normal(0, 1), -3, 3)) x = [mean(d) for d in dists] pdf_f = let dists = dists