Skip to content

Commit

Permalink
FIx TransformedAdaptiveMHTuning and example
Browse files Browse the repository at this point in the history
  • Loading branch information
oschulz committed Jul 6, 2023
1 parent 9cb2625 commit bb97b3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions examples/dev-internal/transformed_example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using BAT.LinearAlgebra
using BAT.Distributions
using BAT.InverseFunctions
import BAT: TransformedMCMCIterator, TransformedAdaptiveMHTuning, TransformedRAMTuner, TransformedMHProposal, TransformedNoTransformedMCMCTempering, transformed_mcmc_step!!, TransformedMCMCTransformedSampleID
using Random123
using Random123, PositiveFactorizations
using AutoDiffOperators

import BAT: mcmc_iterate!, transformed_mcmc_iterate!, TransformedMCMCSampling
Expand All @@ -23,8 +23,8 @@ my_result = @time BAT.bat_sample_impl(posterior, TransformedMCMCSampling(pre_tra
density_notrafo = convert(BAT.AbstractMeasureOrDensity, posterior)
density, trafo = BAT.transform_and_unshape(PriorToGaussian(), density_notrafo)

c = BAT._approx_cov(density)
f = BAT.CustomTransform(Mul(c))
s = cholesky(Positive, BAT._approx_cov(density)).L
f = BAT.CustomTransform(Mul(s))

my_result = @time BAT.bat_sample_impl(posterior, TransformedMCMCSampling(pre_transform=PriorToGaussian(), tuning_alg=TransformedAdaptiveMHTuning(), nchains=4, nsteps=4*100000, adaptive_transform=f), context)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ end

# this function is called once after each tuning cycle
g_state = nothing
function tuning_update!(tuner::TransformedProposalCovTuner, chain::MCMCIterator, samples::DensitySampleVector)
function tuning_update!(tuner::TransformedProposalCovTuner, chain::TransformedMCMCIterator, samples::DensitySampleVector)
global g_state = (;tuner, chain)

stats = tuner.stats
Expand Down

1 comment on commit bb97b3a

@Cornelius-G
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need to revert the change in line 61 of "mcmc_proposalcov_tuner.jl". This makes the CI tests fail. TransformedMCMCIterator' is a subtype of MCMCIteratorbut not yet defined at that point. The dispatch should work fine using only thetuner` argument.

Please sign in to comment.