bat / BAT.jl

A Bayesian Analysis Toolkit in Julia
Other
198 stars 30 forks source link

Fix revert to functional rand(::HierarchicalDistribution) #416

Closed waldie11 closed 1 year ago

waldie11 commented 1 year ago

Only checked the transform in #415 , so now reenable functionality to draw random sample from HierarchicalDistributions / anything calling _hd_split with eff_totalndof ≠ length in primary_dist. No guarantees that there are some calls remaining which should rather work on newly introduced _hd_split_efftotalndof

using BAT
using ValueShapes
using Distributions
using InverseFunctions

d = HierarchicalDistribution(NamedTupleDist(
       a=truncated(Logistic(),0,Inf),
)) do v
       NamedTupleDist(
             b=Dirichlet(10,1/v.a),
       )
end

trafo = BAT.DistributionTransform(Normal,d)
inverse(trafo)(rand(Normal(), BAT.eff_totalndof(d))

rand(d)
rand(unshaped(d))
trafo(rand(d))
oschulz commented 1 year ago

Ok, I'll revert https://github.com/bat/BAT.jl/pull/415 until we have this consistent. :-)