File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ DynamicPPLChainRulesCoreExt = ["ChainRulesCore"]
4141DynamicPPLEnzymeCoreExt = [" EnzymeCore" ]
4242DynamicPPLForwardDiffExt = [" ForwardDiff" ]
4343DynamicPPLJETExt = [" JET" ]
44- DynamicPPLMCMCChainsExt = [" MCMCChains" ]
44+ DynamicPPLMCMCChainsExt = [" MCMCChains" , " Statistics " ]
4545DynamicPPLMarginalLogDensitiesExt = [" MarginalLogDensities" ]
4646DynamicPPLMooncakeExt = [" Mooncake" ]
4747
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ module DynamicPPLMCMCChainsExt
22
33using DynamicPPL: DynamicPPL, AbstractPPL, AbstractMCMC
44using MCMCChains: MCMCChains
5+ using Statistics: mean
56
67_has_varname_to_symbol (info:: NamedTuple{names} ) where {names} = :varname_to_symbol in names
78
@@ -165,12 +166,20 @@ function AbstractMCMC.bundle_samples(
165166 info = merge (info, (start_time= stats. start, stop_time= stats. stop))
166167 end
167168
169+ # Calculate logevidence, if it's available
170+ logevidence = if :logevidence in names (bare_chain)
171+ mean (bare_chain[:logevidence ])
172+ else
173+ missing
174+ end
175+
168176 # Reconstruct the chain with the extra information
169177 # Yeah, this is quite ugly. Blame MCMCChains.
170178 chain = MCMCChains. Chains (
171179 bare_chain. value. data,
172180 names (bare_chain),
173181 bare_chain. name_map;
182+ evidence= logevidence,
174183 info= info,
175184 start= discard_initial + 1 ,
176185 thin= thinning,
You can’t perform that action at this time.
0 commit comments