FriesischScott / UncertaintyQuantification.jl

Uncertainty Quantification in Julia
MIT License
28 stars 7 forks source link

Bayesian updating framework #63

Closed FriesischScott closed 2 months ago

FriesischScott commented 2 years ago

This is where I'll update/improve the framework to better integrate it into the existing code base.

FriesischScott commented 2 years ago

Implemented right now are

along with some helper methods.

To clean this up I would like to unify the interface somehow. My suggestion:

Have all methods called bayesian_inference() or some variation of it. These will take the values that are the same among all algorithms while the extra parameters are grouped into structs like

struct TransitionalMarkovChainMonteCarlo begin
    ...
end

struct SequentialMonteCarlo begin
    ...
end

For metropolis-hastings as well as tmcmc we would just wrap around TransitionalMCMC.jl if possible. No need to reinvent the wheel.

FriesischScott commented 1 year ago

Ideally, the method signature would include the arguments that all of the methods have (if they exist). Like

function bayesian_model_updating(likelihood::Function, prior::Function, bmu::AbstractBayesianModelUpdating)
    ...
end

where the bmu includes everything else based on the method that should be used (Transitional, Sequential, MH, etc.). If that makes sense.

Having a common interface and grouping the extras in the struct seems fairly reasonable. Not 100% sure though.

codecov[bot] commented 7 months ago

Codecov Report

Attention: Patch coverage is 81.89655% with 21 lines in your changes missing coverage. Please review.

Project coverage is 90.16%. Comparing base (69f74ff) to head (97f51ad). Report is 2 commits behind head on master.

:exclamation: Current head 97f51ad differs from pull request most recent head 5985448

Please upload reports for the commit 5985448 to get more accurate results.

Files Patch % Lines
src/modelupdating/bayesianupdating.jl 81.89% 21 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #63 +/- ## ========================================== - Coverage 90.95% 90.16% -0.80% ========================================== Files 27 29 +2 Lines 1084 1250 +166 ========================================== + Hits 986 1127 +141 - Misses 98 123 +25 ```

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

AnderGray commented 2 months ago

For testing of MCMC methods in bayesian updating, we can use conjugate priors to get analytical solutions to simple updating problems.

There are tables in wikipedia: https://en.wikipedia.org/wiki/Conjugate_prior

For example a prior and likelihood which are both normal, will also produce a normal posterior. The parameters of the posterior depend on the parameters of the prior and likelihood. The updating rules can be found in the tables.

FriesischScott commented 2 months ago

I will write a bit of documentation before the merge. Code -wise, it should be OK for now. We can always extend with more algorithms in the future.