Package: pyemcee
Descriptionpyemceeis a Python implementation of theaffine-invariant Markov chain Monte Carlo (MCMC) ensemble sampler, based onsl_emceebyM. A. Nowak, an S-Lang/ISISimplementation of the MCMC Hammer proposed byGoodman & Weare (2010), and also implemented in Python (emcee) byForeman-Mackey et al. (2013).InstallationTo install the last version, all you should need to do is$ python setup.py installTo install the stable version, you can use the preferred installer program (pip):$ pip install pyemceeor you can install it from the cross-platform package managerconda:$ conda install -c conda-forge pyemceeThis package requires the following packages:NumPySciPyMatplotlibHow to UseThe Documentation of the functions provides in detail in theAPI Documentation(mcfit.github.io/pyemcee/doc). This Python library creates the MCMC sampling  for given upper and lower uncertainties, and propagates uncertainties of parameters into the function.SeeJupyter Notebook:Notebook.ipynbRunJupyter NotebookonBinder:First, you need to load thepyemceelibrary as follows:importpyemceeimportnumpyasnpYou need to define your function. For example:defmyfunc21(input1):result1=np.sum(input1)result2=input1[1]**input1[0]return[result1,result2]Then, specify the upper and lower uncertainties of the prior parameters:input1=np.array([1.,2.])input1_err=np.array([0.2,0.5])input1_err_p=input1_errinput1_err_m=-input1_erroutput1=myfunc21(input1)output1_num=len(output1)Choose the appropriate uncertainty distribution. For example, for a uniform distribution, use_gaussian=0, and a Gaussian distribution use_gaussian=1. Then, specify the number of walkers and the number of iterations, e.g. walk_num=30 and iteration_num=100. You can then create the MCMC sample and propagate the uncertainties of the input parameters into your defined functions as follows:use_gaussian=0# uniform distribution from min value to max valuewalk_num=30# number of walkersiteration_num=100# number of samplersmcmc_sim=pyemcee.hammer(myfunc21,input1,input1_err_m,input1_err_p,output1,walk_num,iteration_num,use_gaussian)To determine the upper and lower errors of the function outputs, you need to run with the chosen appropriate confidence level. For example, a 1.645-sigma standard deviation can be specified with clevel=0.90. For a 1-sigma standard deviation, we have clevel=0.682:clevel=0.68268949# 1-sigmaoutput1_error=pyemcee.find_errors(output1,mcmc_sim,clevel,do_plot=1)which shows the following distribution histograms:To prevent plotting, you should set do_plot=None. To print the results:foriinrange(0,output1_num):print(output1[i],output1_error[i,:])which provide the upper and lower limits on each parameter:3.0 [-0.35801017 0.35998471]
2.0 [-0.37573196 0.36297235]For other standard deviation, you should use different confidence levels:clevel=0.38292492# 0.5-sigmaclevel=0.68268949# 1.0-sigmaclevel=0.86638560# 1.5-sigmaclevel=0.90# 1.645-sigmaclevel=0.95# 1.960-sigmaclevel=0.95449974# 2.0-sigmaclevel=0.98758067# 2.5-sigmaclevel=0.99# 2.575-sigmaclevel=0.99730020# 3.0-sigmaclevel=0.99953474# 3.5-sigmaclevel=0.99993666# 4.0-sigmaclevel=0.99999320# 4.5-sigmaclevel=0.99999943# 5.0-sigmaclevel=0.99999996# 5.5-sigmaclevel=0.999999998# 6.0-sigmaDocumentationFor more information on how to use the API functions from the pyemcee library, please read theAPI Documentationpublished onmcfit.github.io/pyemcee.Learn MoreDocumentationhttps://pyemcee.readthedocs.io/Repositoryhttps://github.com/mcfit/pyemceeIssues & Ideashttps://github.com/mcfit/pyemcee/issuesConda-Forgehttps://anaconda.org/conda-forge/pyemceePyPIhttps://pypi.org/project/pyemcee/Archive10.5281/zenodo.4495911