ICB-DCM / pyPESTO

python Parameter EStimation TOolbox
https://pypesto.readthedocs.io
BSD 3-Clause "New" or "Revised" License
216 stars 47 forks source link

Adding Thermodynamic Integration #1326

Closed arrjon closed 5 months ago

arrjon commented 5 months ago

I added a small function compute_log_evidence to the ParallelTemperingSampler which allows one to compute the log-evidence of a model after sampling. This is based on thermodynamic integration, which computes the integral over the mean log likelihood, where the mean is taken over the samples from the tempered posteriors. Usually a different temperature schedule is used with thermodynamic integration, which can be added as an option during sampling by

sampler = sample.ParallelTemperingSampler(
            internal_sampler=sample.AdaptiveMetropolisSampler(),
            options={"beta_init": "beta_decay"},
            n_chains=n_chains,
)

The evidence can be calculated by

 log_evidence = compute_log_evidence(result)
codecov-commenter commented 5 months ago

Codecov Report

Attention: Patch coverage is 85.71429% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 84.47%. Comparing base (f2b64d1) to head (adb107a).

Files Patch % Lines
pypesto/sample/parallel_tempering.py 85.71% 4 Missing :warning:
pypesto/sample/adaptive_parallel_tempering.py 80.00% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1326 +/- ## =========================================== + Coverage 84.39% 84.47% +0.08% =========================================== Files 153 153 Lines 12482 12515 +33 =========================================== + Hits 10534 10572 +38 + Misses 1948 1943 -5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.