BAMresearch / bayem

Implementation and derivation of "Variational Bayesian inference for a nonlinear forward model." [Chappell et al. 2008] for arbitrary, user-defined model errors.
MIT License
2 stars 1 forks source link

Add optional parameter_names to MVN #28

Closed TTitscher closed 3 years ago

TTitscher commented 3 years ago

If you provide the additional argument parameter_names (e.g. ["A1", "B1", "A2", "B2"] in one test case) to bayes.vb.MVN, the __str__ method now returns

  param:         MVN posterior with 
                  ├── A1 µ=100.688020 σ=  0.819414 
                  ├── B1 µ=199.706033 σ=  0.481305 
                  ├── A2 µ=301.032772 σ=  0.819414 
                  ├── B2 µ=400.063915 σ=  0.481305 

instead of

  param:         MVN with 
                  ├── mean: [ 1.007e+02  1.997e+02  3.010e+02  4.001e+02]
                  ├── std:  [ 8.194e-01  4.813e-01  8.194e-01  4.813e-01]

You can also access the individual parameters via

mvn.named_mean("A1")  # = 100.688020
mvn.named_sd("B2") # = 0.481305