{ "info": { "author": "E. E. O. Ishida, S. D. P. Vitenti, M. Penna-Lima,J. Cisewski, R. S. de Souza, A. M. M. Trindade, V. C. Busti, E. Cameron", "author_email": "emilleishida@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: X11 Applications", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License (GPL)", "Natural Language :: English", "Programming Language :: Python", "Topic :: Scientific/Engineering :: Astronomy", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": ".. image:: nstatic/COIN.jpg\n\n\n\ncosmoabc - Likelihood free inference for cosmology\n==================================================\n\n\n``cosmoabc`` is a package which enables parameter inference using an Approximate Bayesian Computation (ABC) algorithm, as described in `Ishida et al., 2015 `_.\n\nThe code was originally designed for cosmological parameter inference from galaxy clusters number counts based on Sunyaev-Zel'dovich measurements. In this context, the cosmological simulations were performed using the `NumCosmo library `_ .\n\nNevertheless, the user can easily take advantage of the ABC sampler along with his/her own simulator, as well as test personalized prior distributions and distance functions. \n\n\nGet it now!\n***********\n\nThe package can be installed using the PyPI and pip::\n\n $ pip install cosmoabc\n\nOr if the tarball or repository is downloaded, in the cosmoabc directory you can install and test it::\n\n $ python setup.py install\n\nYou can run a few tests with::\n\n $ test_ABC_algorithm.py\n\n.. warning:: \n The above tests will generate a lot of output data file and a pdf file with their graphical representation. \n This was chosen to facilitate the identification of errors. \n\n Make sure to run the tests in their own directory. \n\nThe test outputs a file illustrating the evolution of the posterior.\n\n.. image:: nstatic/results_gaussian_sim.gif\n\nInput Parameter File\n********************\n\nSample input in can be found in ``~cosmoabc/examples``. All example files mentioned in this section are available in that directory. \n\nThe user input file should contain all necessary variables for simulation as well as for the ABC sampler.\n\nA simple example of user input file, using a simulator which takes 3 parameters as input (``mean``, ``std``, ``n``) from which we want to fit only two (``mean``, ``std``), would look like this ::\n\n path_to_obs\t\t= None \t # path to observed data \n\n param_to_fit \t= mean \tstd \t # parameters to fit\n param_to_sim \t= mean std n\t # parameters needed for simulation\n\n prior_func\t = my_prior flat_prior # one prior function for each parameter\n # under consideration\n\n mean_prior_par_name = pmin pmax # parameters for prior distribution \n mean_prior_par_val = -2.0 4.0 # values for prior distribution \n\n std_prior_par_name = pmin pmax # parameters for prior distribution\n std_prior_par_val = 0.1 5.0 # values for prior distribution\n\t\n mean_lim = -2.0 4.0 # extreme limits for parametes\n std_lim = 0.1 5.0 #\n\t\t \n mean\t\t = 2.0 # parameters values need for simulation\n std\t\t= 1.0 #\n n\t\t= 1000 #\n\n M \t\t= 100\t\t\t\t # number of particle in each particle system\n Mini = 200 # number of draws for 1st particle system\n delta = 0.25\t\t\t\t # convergence criteria\n qthreshold \t= 0.75\t\t\t\t # quantile in distance threshold \n\n file_root \t = toy_model_PS # root to output files names \n screen = 0\t\t\t # rather (1) or not (0) to screen outputs\n ncores = 1\t\t\t\t # number of cores\n split_output = 1 # number of intermediate steps written to file\n\n simulation_func = my_simulation # simulation function\n distance_func = my_distance # distance function\n\n\nImportant notes on input parameters\n-----------------------------------\n\n* In the current implementation, it is important to include a `` # `` symbol preceded and followed by a white space after the definition of each variable in the input file. \n\n* The variable ``path_to_obs`` can be set to ``None``, in this case, ``cosmoabc`` will generate one catalogue from the simulator and consider it as the *observed* catalogue. It will also output this catalogue to a data file, so it can be used for further scrutnity.\n\n* If you are using your own prior function, you are free to name the prior parameters as you wish, you only need to define ``_prior_par_name`` and ``_prior_par_val`` accordingly. If you have doubts about variable names, a quick comparison between the two example input files (toy model and NumCosmo) might help. \n\n* The parameter ``split_output`` determines how many sub-sets of particles you wish to generate for each particle system. Its goal is to avoid the lost of partial results for an enventual problem when dealing with very complex, and time consuming, simulators. If you are only making a quick test and has no intention to keep partial results, just set ``split_output = 1``. \n\n\nSimulation, distance and prior functions\n****************************************\n\nThe most important ingredients in an ABC analysis are:\n\n* the prior probability distributions (PDF)\n* the simulator\n* the distance function\n\nBuilt-in options for priors PDF are:\n\n* Gaussian\n* flat\n* beta\n\nBuilt-in option for simulations is:\n\n* NumCosmo simulation\n\nBuilt-in options for distance functions are:\n\n* Quantile-based distance with number of objects criteria\n* Gaussian Radial Basis Function distance (as descrived in Appendix B of `Ishida et al., 2015 `_)\n\nMoreover, ``cosmoabc`` is also able to handle user defined functions for all three elements. \nYou will find example files which will help you tailor your functions for the ABC sampler. \n\nOnce all the function definitions are determined, the ABC sampler can be called from the command line::\n\n $ run_ABC.py -i -f \n\nThis will run the algorithm until the convergence criteria is reached. A pdf file containing graphical representation of the results for each particle system is \ngiven as output, as well as numerical data files. \n\nIf the achieved result is not satisfactory, or if for some reason the calculation was stopped before reaching the convergence criteria, it is possible to run the ABC sampler beginning from the last completed particle system ``N``. \n\nFrom the command line::\n\n $ continue_ABC.py -i -f -p N\n\nIn case the convergence criteria was achieved but you wish to continue the run, remember to decrease the convergence criteria ``delta`` in the ```` before continuing. \n\nAt any time it is possible to plot the outcomes from ``N`` particle systems, whose calculations were completed, using::\n\n $ plot_ABC.py -i -p N\n\nIt is also possible to use it interactively.\nConsidering we are using built-in simulation, prior and distance functions, \n\n.. code-block:: python \n\n from cosmoabc.priors import flat_prior\n from cosmoabc.ABC_sampler import ABC\n from cosmoabc.ABC_functions import read_input\n from cosmoabc.plots import plot_2D\n import numpy as np\n \n #user input file\n filename = 'user.input'\n\n #read user input\n Parameters = read_input(filename)\n\n #initiate ABC sampler\n sampler_ABC = ABC(params=Parameters) \n\n #build first particle system\n sys1 = sampler_ABC.BuildFirstPSystem()\n\n #update particle system until convergence\n sampler_ABC.fullABC()\n\n #plot results\n plot_2D( sampler_ABC.T, 'results.pdf' , params)\n\n\nIf you are using your own functions, remember to update the dictionary of parameters and determine the dimension of its output manually,\n\n.. code-block:: python\n\n from cosmoabc.priors import flat_prior\n from cosmoabc.ABC_sampler import ABC\n from cosmoabc.ABC_functions import read_input\n from cosmoabc.plots import plot_2D\n\n import numpy as np\n\n from my_functions import my_distance, my_sim, my_prior\n \n #user input file\n filename = 'user.input'\n\n #read user input\n Parameters = read_input(filename)\n\n # update dictionary of user input parameters\n Parameters['distance_func'] = my_distance\n Parameters['simulation_func'] = my_sim\n\n # update the dictionary of prior parameters for each parameter\n Parameters['prior']['mean']['func'] = my_prior\n \n # in case you want to generate a pseudo-observed data set\n Parameters['dataset1'] = my_sim(Parameters['simulation_input'])\n\n #calculate distance between 2 catalogues\n dtemp = my_distance(Parameters['dataset1'], Parameters)\n\n #determine dimension of distance output\n Parameters['dist_dim'] = len(dtemp)\n\n #initiate ABC sampler\n sampler_ABC = ABC(params=Parameters) \n\n #build first particle system\n sys1 = sampler_ABC.BuildFirstPSystem()\n\n #update particle system until convergence\n sampler_ABC.fullABC()\n\n #plot results\n plot_2D( sampler_ABC.T, 'results.pdf' , Parameters)\n\n.. warning:: \n | When using your own **distance function** remember that it must take as input:\n | - a catalogue and \n | - a dictionary of input parameters\n |\n | When using your own **prior function**, it must take as input:\n | - a dictionary of input parameters\n | - a boolean variable ``func`` (optional):\n | if ``func`` is ``False`` returns one sampling of the underlying distribution\n | if ``func`` is ``True`` returns the PDF itself\n\n\nNumCosmo simulations\n--------------------\n\nIn order to reproduce the results of `Ishida et al., 2015 `_, first you need to make sure the NumCosmo library is running smoothly. \nInstructions for complete installation and tests can be found at the `NumCosmo website `_.\n\nAn example of input file for NumCosmo simulations is provided in the corresponding directory.\nOnce the simulator is installed run the complete ABC sampler + NumCosmo cluster simulations from the command line::\n\n $ run_ABC_NumCosmo.py -i \n\n\nThis will run the complete analysis presented in the above paper.\n\nAnalogously to what is available for the user defined simulations, we can also continue a NumCosmo calculation from particle system ``N`` with::\n\n $ continue_ABC_NumCosmo.py -i -p N\n\nIf we want to run the NumCosmo simulation with a different prior or distance function, we should define it in a separate file and run::\n\n $ run_ABC_NumCosmo.py -i -f \n\nPlots are generated exactly as explained above for the user defined functions.\n\nTesting Distances\n*****************\n\nIf you are using a personalized distance, make sure that it applies to the particular problem you are facing. \nYou need to be sure that the distance definition you adpoted yields increasingly larger distances for increasingly different catalogues. \n\n``cosmoabc`` has a built-in script which allows you to visually test the performances of your choices. \nIn order to use it, prepare an appropriate user input and function files and, from the command line, do::\n\n $ test_ABC_distance.py -i -f -o \n\nHere, ```` is where the distance behaviour for different set of parameter values will be plotted. \n\nAs always, the ```` must be provided. \nIf you are using built-in ``cosmoabc`` functions, the ``-f`` option is not necessary and in case you forget to give an output filename, ``cosmoabc`` will ask you for it. \nIt will also ask you to input the number of points to be drawn from the parameter space in order to construct a grid. \n\nHere is an example from using the built-in tool to check the suitability of the distance function described in section 3.1 of the paper::\n\n $ test_ABC_distance.py -i user_input_file.dat -f user_function_file.dat \n $ Distance between identical cataloges = [ 0.]\n $ New parameter value = [ 0.41054026 0.6364732 ]\n $ Distance between observed and simulated data = [804.38711094885957]\n $ Enter number of draws in parameter grid: 5000 \n $ Particle index: 1\n $ Particle index: 2\n $ Particle index: 3\n $ Particle index: 4\n $ ...\n $ Particle index: 5000\n $ Figure containing distance results is stored in output.pdf\n\nThe output file will contain a plot like this:\n\n.. image:: nstatic/distance_toy_model.png\n \n\nThe example above corresponds to a perfect distance definition, since it gets close to zero as parameters ``mean`` and ``std`` approaches the fiducial values and sharply increases for further values.\n\nThis is what one should aim for in constructing a distance function. \nHow large a deviation from this is acceptable should be decided based on each particular problem and goal. \n\nBibtex entry \n************\n\nIf you use ``cosmoabc`` in you research, we kindly ask you to cite the original paper.\nThe code includes a built-in citation function which outputs the bibtex entry\n\n.. code-block:: python\n\n import cosmoabc\n \n cosmoabc.__cite__()\n\nthis will return::\n\n @ARTICLE{2015A&C....13....1I,\n author = {{Ishida}, E.~E.~O. and {Vitenti}, S.~D.~P. and {Penna-Lima}, M. and \n\t {Cisewski}, J. and {de Souza}, R.~S. and {Trindade}, A.~M.~M. and \n\t {Cameron}, E. and {Busti}, V.~C.},\n title = \"{COSMOABC: Likelihood-free inference via Population Monte Carlo Approximate Bayesian Computation}\",\n journal = {Astronomy and Computing},\n archivePrefix = \"arXiv\",\n eprint = {1504.06129},\n keywords = {Galaxies: statistics, (cosmology:) large-scale structure of universe},\n year = 2015,\n month = nov,\n volume = 13,\n pages = {1-11},\n doi = {10.1016/j.ascom.2015.09.001},\n adsurl = {http://adsabs.harvard.edu/abs/2015A%26C....13....1I},\n adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n}\n\n\n \n\n\nRequirements\n************\n\n* Python 2.7\n* numpy >=1.8.2\n* scipy >= 0.14.0\n* statsmodels >= 0.5.0\n* matplotlib >= 1.3.1 \n* argparse >= 1.1\n* multiprocessing >= 0.70a1\n\n\n\nOptional\n--------\n\n* `NumCosmo `_\n\n\nLicense\n********\n\n* GNU General Public License (GPL>=3)\n\n\nThe Cosmostatistics Initiative (COIN)\n*************************************\n\nThe IAA Cosmostatistics Initiative (`COIN `_) is a non-profit organization whose aim is to nourish the synergy between astrophysics, cosmology, statistics and machine learning communities. \nThis work is a product of the first COIN Summer Residence Program, Lisbon, August/2014.\n\nOther projects developed under COIN can be found in the `COINtoolbox `_\n\nAcknowledgements\n****************\n\nIn order to give proper credit to the online sources used in the development of this work, we list bellow the main websites, foruns and blogs which were used in different parts of its development. **We deeply thank everyone who contributes to open learning plataforms**.\n\n`Multiprocessing and KeyboarInterrupt `_\n\n`Ordering gif `_\n\n`Plotting `_\n\n`Remembering git commands `_\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/COINtoolbox/cosmoabc", "keywords": "", "license": "GNU Public License", "maintainer": "", "maintainer_email": "", "name": "cosmoabc", "package_url": "https://pypi.org/project/cosmoabc/", "platform": "", "project_url": "https://pypi.org/project/cosmoabc/", "project_urls": { "Homepage": "https://github.com/COINtoolbox/cosmoabc" }, "release_url": "https://pypi.org/project/cosmoabc/1.0.9/", "requires_dist": null, "requires_python": "", "summary": "Python ABC sampler", "version": "1.0.9" }, "last_serial": 3538555, "releases": { "1.0": [], "1.0.1": [ { "comment_text": "", "digests": { "md5": "0f760090575fd232257bf6f2cd5f2211", "sha256": "d3bb510ee978531340949513d0965a82854a0148a8da6222c3660ae490dfa58c" }, "downloads": -1, "filename": "cosmoabc-1.0.1.tar.gz", "has_sig": false, "md5_digest": "0f760090575fd232257bf6f2cd5f2211", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49171, "upload_time": "2015-05-12T00:54:27", "url": "https://files.pythonhosted.org/packages/93/9d/b1d59952935c8022bbe676ad6a75b37fcd323160ed69ac9dc45b1249718a/cosmoabc-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "0d0bbc7605b87ba7b8e0cc0082064a13", "sha256": "fa8aa497e9e4f4a693f22044f9dcb7f1f49c15f2bdb7e9a685da92d921afd6dc" }, "downloads": -1, "filename": "cosmoabc-1.0.2.tar.gz", "has_sig": false, "md5_digest": "0d0bbc7605b87ba7b8e0cc0082064a13", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49204, "upload_time": "2015-05-16T21:14:42", "url": "https://files.pythonhosted.org/packages/62/ee/fd80f3f64ae4930344ab1e0c7416a268d7a2c84964056900d5c4bd32f0a2/cosmoabc-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "eac37d22dbda2dca4dad9d431d7036f3", "sha256": "1eee1af89877a824fe136f2901001224bd5f4da8b067e09fb457dd34a01ed121" }, "downloads": -1, "filename": "cosmoabc-1.0.3.tar.gz", "has_sig": false, "md5_digest": "eac37d22dbda2dca4dad9d431d7036f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49212, "upload_time": "2015-05-18T12:29:27", "url": "https://files.pythonhosted.org/packages/69/79/6fe1b5a12ed65a716007486f02da7f2df0867ab7f78e7d989ff1de0dd5b4/cosmoabc-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "00f298907898048097d6989a4280d56c", "sha256": "34215ad69ce3ac0c071202d8a4f00cd16b7cc06d37a310eddffca222e344a459" }, "downloads": -1, "filename": "cosmoabc-1.0.4.tar.gz", "has_sig": false, "md5_digest": "00f298907898048097d6989a4280d56c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49246, "upload_time": "2015-05-19T18:57:17", "url": "https://files.pythonhosted.org/packages/2a/66/4e7d60c4c8e8626ed752934267287892b71e4116a7d7a0a920fc2ca9870c/cosmoabc-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "89f4773b3f52cd483d9ef603d367255c", "sha256": "84ac7195a3b86fd756ec88f01787d976a63c115c46b907df3e9e6ba60538622e" }, "downloads": -1, "filename": "cosmoabc-1.0.5-py2.7.egg", "has_sig": false, "md5_digest": "89f4773b3f52cd483d9ef603d367255c", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 109580, "upload_time": "2017-11-15T08:20:39", "url": "https://files.pythonhosted.org/packages/35/e6/e36510ce31bf3d4aba17cc9b6f3ef601bc090029ff57995942f15396640c/cosmoabc-1.0.5-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "47aa7b6a5bb18f01d0fc2ead6b812baa", "sha256": "abf7f8d9079974afc6619cdef024f966cef4074eb11471ee196934e6abee7d11" }, "downloads": -1, "filename": "cosmoabc-1.0.5.tar.gz", "has_sig": false, "md5_digest": "47aa7b6a5bb18f01d0fc2ead6b812baa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 48259, "upload_time": "2015-05-21T00:43:15", "url": "https://files.pythonhosted.org/packages/2c/23/ae40f01b60e55a5559a697a2cfc0cf962c3f96230806f80a91a21daaf483/cosmoabc-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "1dfe70090958ab453bace34f53c564f9", "sha256": "e590eb9dc7cba376a4caa9cea03392c56552d238c1db3d6441d056445fbf4866" }, "downloads": -1, "filename": "cosmoabc-1.0.6-py2.7.egg", "has_sig": false, "md5_digest": "1dfe70090958ab453bace34f53c564f9", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 109609, "upload_time": "2017-11-15T08:20:42", "url": "https://files.pythonhosted.org/packages/1a/84/8d3638fd8d1c0c4fad7d2081aa6ef8ea5b65dc202afe34c97f1ba3c8f65d/cosmoabc-1.0.6-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "65b679f20e6c1a16b1e209856df6d886", "sha256": "d5a10a2f34a3cb7ecbd750571fc47b361482d09f7ba0c17138ccd7f5a4d875a8" }, "downloads": -1, "filename": "cosmoabc-1.0.6.tar.gz", "has_sig": false, "md5_digest": "65b679f20e6c1a16b1e209856df6d886", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49087, "upload_time": "2017-11-15T08:20:44", "url": "https://files.pythonhosted.org/packages/93/9d/b49f05aebe0ed939caad3017b3320373582ef047bdbaedbe1de8276b08b9/cosmoabc-1.0.6.tar.gz" } ], "1.0.7": [ { "comment_text": "", "digests": { "md5": "5cea24801cf9cdea3691148793d1fdfe", "sha256": "f61f3cbc96ec06d5ba02f0a22f9ac8da8128395882cb185c9ee794cf02fa38b7" }, "downloads": -1, "filename": "cosmoabc-1.0.7.tar.gz", "has_sig": false, "md5_digest": "5cea24801cf9cdea3691148793d1fdfe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49122, "upload_time": "2017-11-15T08:20:46", "url": "https://files.pythonhosted.org/packages/31/6a/485cd1cada7a852882fce792b3abe9c6003b032d6c7eaa8277808dfe2d71/cosmoabc-1.0.7.tar.gz" } ], "1.0.8": [ { "comment_text": "", "digests": { "md5": "8a1add282d3cc4c544ab012a29813022", "sha256": "0401e0a7e29a3b46ead659dca3f77e720e9bb3e389bb9b57fa9bbf751082aecf" }, "downloads": -1, "filename": "cosmoabc-1.0.8.tar.gz", "has_sig": false, "md5_digest": "8a1add282d3cc4c544ab012a29813022", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49279, "upload_time": "2018-01-31T14:20:59", "url": "https://files.pythonhosted.org/packages/fb/58/fdebdf97904ac7ba15e405d1b942d89c4d1f67c9f2c6e819a1ecf0c4f398/cosmoabc-1.0.8.tar.gz" } ], "1.0.9": [ { "comment_text": "", "digests": { "md5": "b78e38bcf306d9772cfd4407baae952a", "sha256": "b2282d6339f9ece6798134b55dfa452eefda32132c9efb4639374c511a4a8e97" }, "downloads": -1, "filename": "cosmoabc-1.0.9.tar.gz", "has_sig": false, "md5_digest": "b78e38bcf306d9772cfd4407baae952a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49300, "upload_time": "2018-01-31T14:49:09", "url": "https://files.pythonhosted.org/packages/cf/f9/2c2db2d386fefa7614785b12d33fed0c8256023639356c2c793232df3566/cosmoabc-1.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b78e38bcf306d9772cfd4407baae952a", "sha256": "b2282d6339f9ece6798134b55dfa452eefda32132c9efb4639374c511a4a8e97" }, "downloads": -1, "filename": "cosmoabc-1.0.9.tar.gz", "has_sig": false, "md5_digest": "b78e38bcf306d9772cfd4407baae952a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49300, "upload_time": "2018-01-31T14:49:09", "url": "https://files.pythonhosted.org/packages/cf/f9/2c2db2d386fefa7614785b12d33fed0c8256023639356c2c793232df3566/cosmoabc-1.0.9.tar.gz" } ] }