Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bayesian inference with multidimensional prior #43

Closed
MaurusGubser opened this issue Nov 26, 2021 · 1 comment
Closed

Bayesian inference with multidimensional prior #43

MaurusGubser opened this issue Nov 26, 2021 · 1 comment

Comments

@MaurusGubser
Copy link

When running the PMMH algorithm with verbose non-zero and a prior for a non-scalar parameter, there's a bug in the print_progress method in the MCMC class:

    def print_progress(self, n):
        params = self.chain.theta.dtype.fields.keys()
        msg = 'Iteration %i' % n
        if hasattr(self, 'nacc') and n > 0:
            msg += ', acc. rate=%.3f' % (self.nacc / n)
        for p in params:
            msg += ', %s=%.3f' % (p, self.chain.theta[p][n])
        print(msg)

In the case of a prior for a non-scalar parameter, self.chain.theta[p][n] is an array and one has to use another kind of string formatting.

NB: It's not much of a problem. If verbose=0 or one can factor the multidimensional parameter into scalar parameters, everything works fine.

@nchopin
Copy link
Owner

nchopin commented Nov 26, 2021

OK, I replaced %.3f by %s, which should work whether self.chaintheta[p][n] is a scalar or or an array. (We loose the formatting, but I guess that's ok.)
Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants