AdaMet: Adaptive Metropolis for Bayesian Analysis
Project description
Adaptive Metropolis for Bayesian Analysis
AdaMet is a well-tested Python implementation by Cappellari et al. (2013) of the Adaptive Metropolis algorithm by Haario H., Saksman E., Tamminen J. (2001). It was used in a number of published papers in the astrophysics literature.
Attribution
If you use this software for your research, please cite at least Cappellari et al. (2013) where the implementation was introduced. The BibTeX entry for the paper is:
@ARTICLE{Cappellari2013a, author = {{Cappellari}, M. and {Scott}, N. and {Alatalo}, K. and {Blitz}, L. and {Bois}, M. and {Bournaud}, F. and {Bureau}, M. and {Crocker}, A.~F. and {Davies}, R.~L. and {Davis}, T.~A. and {de Zeeuw}, P.~T. and {Duc}, P.-A. and {Emsellem}, E. and {Khochfar}, S. and {Krajnovi{\'c}}, D. and {Kuntschner}, H. and {McDermid}, R.~M. and {Morganti}, R. and {Naab}, T. and {Oosterloo}, T. and {Sarzi}, M. and {Serra}, P. and {Weijmans}, A.-M. and {Young}, L.~M.}, title = "{The ATLAS$^{3D}$ project - XV. Benchmark for early-type galaxies scaling relations from 260 dynamical models: mass-to-light ratio, dark matter, Fundamental Plane and Mass Plane}", journal = {MNRAS}, eprint = {1208.3522}, year = 2013, volume = 432, pages = {1709-1741}, doi = {10.1093/mnras/stt562} }
Installation
install with:
pip install adamet
Without writing access to the global site-packages directory, use:
pip install --user adamet
Documentation
The documentation is in the docstring of the file adamet.py or on PyPi.
AdaMet Purpose
This is the implementation by Cappellari et al. (2013) of the Adaptive Metropolis algorithm by Haario H., Saksman E., Tamminen J. (2001) for Bayesian analysis.
Usage Example
To learn how to use AdaMet run the example program in the adamet/examples directory, within the main package installation folder inside site-packages, and read the detailed documentation in the docstring of the file adamet.py or on PyPi.
Note: For dimensions = 1 to 6, the optimal acceptance rates are rate = [0.441, 0.352, 0.316, 0.279, 0.275, 0.266] and the asymptotic value for many parameters is 23%
Calling Sequence
pars, lnprob = adamet(lnprob_fun, pars0, sigpars0, bounds, nstep,
labels=None, nprint=100, quiet=False, fignum=None, plot=True,
labels_scaling=1, seed=None, args=(), kwargs={})
Input Parameters
- lnprob_fun: callable
This function returns the natural logarithm of the conditional probability of the model, given the data:
P(model | data) ~ P(data | model) P(model)
- pars0: array_like with shape (n,)
vector with the mean of the multivariate Gaussian describing the proposal distribution from which samples are drawn. For maximum efficiency, this initial Gaussian should approximate the posterior distribution. This suggests adopting as pars0 an initial guess for the model best-fitting parameters.
- sigpars0: array_like with shape (n,)
vector with the dispersion sigma of the multivariate Gaussian describing the proposal distribution. For maximum efficiency, this initial Gaussian should approximate the posterior distribution. This suggests adopting as sigpars an initial guess of the uncertainty in the model parameters pars.
- bounds: 2-tuple of array_like
Lower and upper bounds on independent variables. Each array must match the size of pars. The model probability is set to zero outside the bounds. This keyword is also used to define the plotting ranges.
- nsteps: integer
Number of attempted moves in the chain. Typical numbers are a few thousands nsteps.
Optional Keywords
- labels: array_like with shape (n,)
String labels for each parameter to be used in the corner_plot
- nprint: integer
Specifies the frequency for the intermediate plots, in moves. A typical value could be nstep/10.
- plot: boolean, optional
Specifies whether to show a plot of the results or not.
- fignum: integer, optional
Specifies the figure number for the plot.
- labels_scaling: float
Relative scaling for the plotting labels.
- seed: integer
Seed for the random generator. Specify this value for a repeatable random sequence.
- args, kwargs: tuple and dict, optional
Additional arguments passed to lnprob_fun. Both empty by default. The calling signature is lnprob_fun(x, *args, **kwargs).
Output Parameters
- pars: array_like with shape (nsteps, n)
Posterior distribution for the model parameters
- lnprob: array_like with shape (nsteps, n)
Logarithm of the probbaility of the model, given the data, for each set of parameters in the posterior distribution pars.
License
Other/Proprietary License
Copyright (c) 2012-2020 Michele Cappellari
This software is provided as is without any warranty whatsoever. Permission to use, for non-commercial purposes is granted. Permission to modify for personal or internal use is granted, provided this copyright and disclaimer are included in all copies of the software. All other rights are reserved. In particular, redistribution of the code is not allowed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file adamet-2.0.9.tar.gz
.
File metadata
- Download URL: adamet-2.0.9.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b59f7eb1d193ff201a24e66c7872dfc847e344e43cfe94f75bb8ad066afeef2 |
|
MD5 | b295d4cc01079d7db056f6ba82c57c92 |
|
BLAKE2b-256 | 40907b1175702b1810a1f36493de99ce679b557a7bea61f08ae41f7d94cc10f9 |
File details
Details for the file adamet-2.0.9-py3-none-any.whl
.
File metadata
- Download URL: adamet-2.0.9-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35dfd58e7909cc4d2146ad87e2508962aa54b1d7901622cc15fecfa1a53d8088 |
|
MD5 | b2feb65ee46f8144543f0d9066b9a4e3 |
|
BLAKE2b-256 | 9f92646c976a7b7998a593b89fdca8c3535ce77208c2d41bd153cb109b35ffc2 |