Approximate Bayesian calculation (ABC)
This package conducts ABC on a given model and parameters. Basically, ABayesianC does the following:
-
Sample uniformly from the n-dimensional space of the free parameters
-
Create a parameter set for each of sample set
-
Run the given model for each parameter set and collect the error value
-
Choose the best fits by the rejection algorithm
Getting started
Quick start
pip install --upgrade ABayesianC
# inside your script, e.g. test.py
from ABayesianC import tools
obj = tools.ABC(settings = settings, free_params = free_params)
obj.sample()
obj.run()
obj.postprocess()
More on it
The module receives two inputs from users. First, the free parameters' list that is a python dictionary containing the names and bounds (min and max) of each free parameter, as shown below:
free_params = {
'p_name_1': [1.1,4.3], # [min,max]/ Prior
'p_name_2': [6.4,23.1]
}
Second, the settings variable that is another python dictionary containing:
settings = {
"MPI_flag": True, # whether to use MPI or not
"sample_n": 10000, # Sample number
"top_n": 100, # Number of top selected samples, i.e. posterior
"output_path": "outputs", # Relative output directory to save the results
"replica_n":3 # number of replica run for each param set
"model": Model # the model that receives the parameter set and returns the error value
}
The provided model must:
- receive a parameter set as argument
- has a function named
run - the
runfunction runs the model and returns back the error/fitness value
Parallel run
To run the constructed script, e.g. test.py, in parallel, commain in terminal,
mpiexec -n available_cpu_core python test.py
available_cpu_core is the CPU core number that user intend to allocate for this process. For more info, see MPI for Python.
Outputs
Among the library outputs are:
samples.txt: the samples in the n-dimensional space of the free parametersdistances.txt: the distances/errors/fitness values obtained for each parameter setbest_distances.txt: the best n distances. n is defined in the settingsposterior.json: the posteriors extracted for each free parameter using top n best fitmedians.json: the medians of the posteriors for each free parameter. These values can be considered as inferred values.
Install
Using pip manager:
pip install --upgrade ABayesianC
Or, download the package and in the root folder, command:
python3 setup.py install
Authors
- Jalil Nourisa
Useful links
Contributing to ABayesianC
In case of encountering a problem, pls report it as an issue or contant the author (jalil.nourisa@gmail.com)
Metadata
Release files for ABayesianC 1.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ABayesianC-1.0.8.tar.gz | 6.6 kB | Without provenance | Details for ABayesianC-1.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ABayesianC-1.0.8-py3-none-any.whl | Python 3 | none | any | Details for ABayesianC-1.0.8-py3-none-any.whl |
Total release size: 13.1 kB
Release files / ABayesianC-1.0.8.tar.gz
| Download URL | ABayesianC-1.0.8.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6c828af74afa9f4e0baf273ecc9431bd7f3594b26f910dc2a1a7b041d8b50d9
|
|
BLAKE2b-256 checksum How to use checksums |
0b9d2f11317bbbac3c62d3a0b5fe6a1374e5282188774f02fa51d60678638739
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.9
|
Release files / ABayesianC-1.0.8-py3-none-any.whl
| Download URL | ABayesianC-1.0.8-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a79bf64dca2e3da95fa04ebfc5512a9ff2b206a3d36066d6dc57b05b5901d56a
|
|
BLAKE2b-256 checksum How to use checksums |
aadb817a6ef1c092b6ba92e1a49552511ed8608e315425173d0a16068037ac17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.9
|
Security for ABayesianC 1.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.