Skip to main content

PRISM: An alternative to MCMC for rapid analysis of models

Project description

PyPI - Latest Release PyPI - Python Versions PyPI - License Travis CI - Build Status AppVeyor - Build Status ReadTheDocs - Build Status CodeCov - Coverage Status

Model dispersion with PRISM; an alternative to MCMC for rapid analysis of models

PRISM is a pure Python 3 package that provides an alternative method to MCMC for analyzing scientific models.

Introduction

Rapid technological advancements allow for both computational resources and observational/experimental instruments to become better, faster and more precise with every passing year. This leads to an ever-increasing amount of scientific data being available and more research questions being raised. As a result, scientific models that attempt to address these questions are becoming more abundant, and are pushing the available resources to the limit as these models incorporate more complex science and more closely resemble reality.

However, as the number of available models increases, they also tend to become more distinct, making it difficult to keep track of their individual qualities. A full analysis of every model would be required in order to recognize these qualities. It is common to employ Markov chain Monte Carlo (MCMC) methods and Bayesian statistics for performing this task. However, as these methods are meant to be used for making approximations of the posterior probability distribution function, there must be a more efficient way of analyzing them.

PRISM tries to tackle this problem by using the Bayes linear approach, the emulation technique and history matching to construct an approximation (‘emulator’) of any given model. The use of these techniques can be seen as special cases of Bayesian statistics, where limited model evaluations are combined with advanced regression techniques, covariances and probability calculations. PRISM is designed to easily facilitate and enhance existing MCMC methods by restricting plausible regions and exploring parameter space efficiently. However, PRISM can additionally be used as a standalone alternative to MCMC for model analysis, providing insight into the behavior of complex scientific models. With PRISM, the time spent on evaluating a model is minimized, providing developers with an advanced model analysis for a fraction of the time required by more traditional methods.

Why use PRISM?

  • Written in pure Python 3, for versatility;

  • Stores results in HDF5-files, allowing for easy user-access;

  • Can be executed in serial or MPI, on any number of processes;

  • Compatible with Windows, Mac OS and Unix-based machines;

  • Accepts any type of model and comparison data;

  • Built as a plug-and-play tool: all main classes can also be used as base classes;

  • Easily linked to any model by writing a single custom ModelLink subclass;

  • Capable of reducing relevant parameter space by factors over 100,000 using only a few thousand model evaluations;

  • Can be used alone for analyzing models, or combined with MCMC for efficient model parameter estimations.

Getting started

Installation

PRISM can be easily installed by either cloning the repository and installing it manually:

$ git clone https://github.com/1313e/PRISM
$ cd PRISM
$ pip install .

or by installing it directly from PyPI with:

$ pip install prism

PRISM can now be imported as a package with import prism. For using PRISM in MPI, mpi4py >= 3.0.0 is required (not installed automatically).

The PRISM package comes with two ModelLink subclasses. These ModelLink subclasses can be used to experiment with PRISM to see how it works. The online docs have several examples explaining the different functionalities of the package.

Running tests

If one wants to run pytests on PRISM, all requirements_dev are required. The easiest way to run the tests is by cloning the repository, installing all requirements and then running pytest on it:

$ git clone https://github.com/1313e/PRISM
$ cd PRISM
$ pip install -r requirements_dev.txt
$ pytest

If PRISM and all requirements_dev are already installed, one can run the tests by running pytest in the installation directory:

$ cd <path_to_installation_directory>/prism
$ pytest

When using Anaconda, the installation directory path is probably of the form <HOME>/anaconda3/envs/<environment_name>/lib/pythonX.X/site-packages.

Example usage

See online docs for a documented explanation on this example.

# Imports
from prism import Pipeline
from prism.modellink import GaussianLink

# Define model data and create ModelLink object
model_data = {3: [3.0, 0.1], 5: [5.0, 0.1], 7: [3.0, 0.1]}
modellink_obj = GaussianLink(model_data=model_data)

# Create Pipeline object
pipe = Pipeline(modellink_obj)

# Construct first iteration of the emulator
pipe.construct()

# Create projections
pipe.project()

Community guidelines

PRISM is an open-source and free-to-use software package (and it always will be), provided under the BSD-3 license.

Users are highly encouraged to make contributions to the package or request new features by opening a GitHub issue. If you would like to contribute to the package, but do not know what, then there are quite a few ToDos in the code that may give you some inspiration. As with contributions, if you find a problem or issue with PRISM, please do not hesitate to open a GitHub issue about it.

And, finally, if you use PRISM as part of your workflow in a scientific publication, please consider including an acknowledgement like “Parts of the results in this work were derived using the PRISM Python package.” and citing the PRISM pipeline paper:

@ARTICLE{2019arXiv190108725V,
   author = {{van der Velden}, E. and {Duffy}, A.~R. and {Croton}, D. and
    {Mutch}, S.~J. and {Sinha}, M.},
    title = "{Model dispersion with PRISM; an alternative to MCMC for rapid analysis of models}",
  journal = {arXiv e-prints},
archivePrefix = "arXiv",
   eprint = {1901.08725},
 primaryClass = "astro-ph.IM",
 keywords = {Astrophysics - Instrumentation and Methods for Astrophysics, Physics - Computational Physics},
     year = 2019,
    month = jan,
   adsurl = {http://adsabs.harvard.edu/abs/2019arXiv190108725V},
  adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prism-1.1.1.tar.gz (136.1 kB view details)

Uploaded Source

Built Distribution

prism-1.1.1-py3-none-any.whl (157.1 kB view details)

Uploaded Python 3

File details

Details for the file prism-1.1.1.tar.gz.

File metadata

  • Download URL: prism-1.1.1.tar.gz
  • Upload date:
  • Size: 136.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.6+

File hashes

Hashes for prism-1.1.1.tar.gz
Algorithm Hash digest
SHA256 c2facd3a71dc63ded6705f14ac142fb1906339e753c366e95c04ec261eb44db6
MD5 5bf007897e7788a03e2e4de3cb6cb10a
BLAKE2b-256 f8aa146cc290906a8d89ba18209c9a85e2aea65fa625aa4db4cce8263c2bcc24

See more details on using hashes here.

File details

Details for the file prism-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: prism-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 157.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.6+

File hashes

Hashes for prism-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5bc3d3d03606513727fe5596972fa7a5ea9445e881269267a7e623c39210567
MD5 c256bdb31713e18adc175be87862b23a
BLAKE2b-256 b198d15f214d7d65c317d01c6017f2f2bb32472909e48432a2aff50c59fdfc25

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page