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

Error Analysis #29

Open
eadkins333 opened this issue Dec 23, 2020 · 3 comments
Open

Error Analysis #29

eadkins333 opened this issue Dec 23, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@eadkins333
Copy link
Collaborator

  • Add LMfit Monte Carlo and Emcee to fit?
  • labfit has the ability include an output which has error bars on each point in a spectrum based on the uncertainty in the parameters.
@eadkins333
Copy link
Collaborator Author

The lmfit documentation specifies that the emcee can "can be used to obtain the posterior probability distribution of parameters, given a set of experimental data," but it "does not actually perform a fit." It instead explores the parameter space around a given solution to determine the probability distribution, but without the explicit goal of attempting to refine the solution. - Minimizer Fitting emcee documentation

Emcee Documentation

defines residuals as data - model

can use residuals as the feed to the emcee function without defining the log likeliehood function by specifying is_weighted = False, it will then automatically assign.

res = lmfit.minimize(residual, method='emcee', nan_policy='omit', burn=300, steps=1000, thin=20, params=mi.params, is_weighted=False, progress=False)

  • progress will print a progress bar if the tqdm package is installed.

Success can be checked by the autocorrelation time and/or acceptance fraction for the walkers. Acceptance fraction plot as number of walkers should be between 0.2 and 0.5

installation of the corner package can allow for plotting of the results, but the Minimizer results

`import corner

emcee_plot = corner.corner(res.flatchain, labels=res.var_names,
truths=list(res.params.valuesdict().values()))`

The minimizer result will print the median of the probability distribution and one sigma quantile estimated as half the difference between the 15.8 and 84.2 quantiles.

The emcee can then be used to calculated the maximum likelihood estimation and various quantiles (code on the linked page)

@eadkins333
Copy link
Collaborator Author

Another solution would be to call the confidence interval function.

https://lmfit.github.io/lmfit-py/confidence.html#label-confidence-advanced

@eadkins333
Copy link
Collaborator Author

In meantime could make an error analysis example

@eadkins333 eadkins333 added the enhancement New feature or request label Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant