My samplers do not converge to maximum likelihood
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.6k
- Forks
- 440
- PR merge metrics
- No merged PRs in 30d
Description
General information:
- emcee version: 3.0.2
- platform: Ubuntu Linux
- installation method (pip/conda/source/other?): source
Problem description:
Expected behavior: The samplers converge to best-fit parameters that have the maximum likelihood
Actual behavior: corner plot shows that parameters converge to a group of parameters that do not have the maximum likelihood. Besides, best-fit parameters are not covered by [16%,84%] range of samples.
What have you tried so far?: I saved every group of parameters called by "log_likelihood" and the corresponding likelihood value returned by "log_likelihood" into a new file. I run MCMC sampling for 2000 steps with 12 chains and burned 0 steps. I found that "get_chain" returns 24000 samples while my file only saved less than 20000 samples. The samples returned by "get_chain" do not converge while samples saved by my file show that they are converged. When I was checking the likelihood value I found that samples do not converge to the best-fit parameters that gave the maximum likelihood. I guess the reason is that the best-fit parameters are too close to the boundary of parameter space defined in "log_prior". Therefore MCMC converged to a local minimum instead of the global minimum. To enlarge the parameter space would make it unphysical. What should I do?
Minimal example:
import emcee
## I paste my "log_likelihood" here.
import numpy as np
import os
def log_likelihood(par, y ,yerr):
p1,p2,p3,p4,p5,p6 = par
model = model(p1,p2,p3,p4,p5,p6)
likelihood = -0.5*np.sum((y-model)**2/yerr**2)
# save parameters called by log_likelihood and likelihood to new files
w = [p1,p2,p3,p4,p5,p6,likelihood]
pid = os.getpid()
f =open(str(pid) + 'csv','a')
csv_writer = csv.writer(f,dialect='excel')
csv_writer.writerow(w)
f.close()
return likelihood
# sample code goes here...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the supplied log_likelihood and the sampling setup for emcee 3.0.2, including the 12 chains, 2000 steps, and zero burn-in. Reproduce the reported difference between get_chain and the parameters written by the callback, then determine whether the sampler behavior can be demonstrated with a complete minimal example. Done means a reproducible diagnosis of the reported convergence discrepancy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100