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

Number of steps cut with fixed parameters #31

Closed
vandalt opened this issue Nov 17, 2020 · 2 comments · Fixed by #32
Closed

Number of steps cut with fixed parameters #31

vandalt opened this issue Nov 17, 2020 · 2 comments · Fixed by #32
Labels
bug Something isn't working

Comments

@vandalt
Copy link
Contributor

vandalt commented Nov 17, 2020

In plot_posterior, when checking the fixed parameter, only axis 0 has :, so axes 1 and 2 both get filtered by the index_sel mask. This results in each fitted parameter having only 4 steps per walker in the corner plot (the shape before the index selection is (nwalkers, nsteps-burnin, nparams) and it goes to (nwalkers, nparams, nparams) after). I fixed this in a fork of the project and I can create a PR (the only modification is shown in the code block below). I checked with a few numpy versions and it does not seem related to a numpy version problem.

    # Check if parameter values were fixed

    index_sel = []
    index_del = []

    # Use only last axis for parameter dimensions
    for i in range(ndim):
        if np.amin(samples[:, :, i]) == np.amax(samples[:, :, i]):
            index_del.append(i)
        else:
            index_sel.append(i)

    samples = samples[:, :, index_sel]
@tomasstolker
Copy link
Owner

Thanks for pointing out that issue @vandalt!

Right, this is something that I had implemented recently. The problem is that the ndim of the stored samples from run_mcmc is 3, while the ndim from run_multinest is 2. In the latter case the shape if (nsamples, nparams).

It would be great if you could create a PR which solves this issues and takes the two ndim cases into account.

By the way, when using FitModel, the run_multinest function has more features compared to run_mcmc and convergences more easily in case the posterior is multimodal. It also returns the evidence which can be used for model comparison.

@vandalt
Copy link
Contributor Author

vandalt commented Nov 18, 2020

Right, I had not tried run_multinest so far so I did not think about that part, thank you.

I will create a PR that handles both cases. Ellipsis would probably be the best way to achieve this (i.e. samples[..., i]).

Thanks for the tip about run_multinest vs run_mcmc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants