PYMC: Markov chain Monte Carlo sampling tool

Source: Internet
Author: User

PYMC is a Python library that implements Bayesian statistical model and Markov chain Montacallo sampling tool fitting algorithm. The flexibility and scalability of PYMC makes it suitable for solving various problems. In addition to the core sampling functions, PYMC also includes statistical output, plotting, goodness-of-fit testing, and convergence diagnosis methods.

Add QQ group 813622576 or Vx;tanzhouyiwean free to receive Python learning materials

Characteristics

PYMC makes Bayesian analysis as easy as possible. Here are some of the features of the PYMC library:

    • Markov chain Monte Carlo algorithm and other algorithms are used to fit Bayesian statistical analysis model.
    • Contains a wide range of commonly used statistical distributions.
    • Use some of the features of the numpy as much as you can.
    • A module that includes a Gaussian modeling process.
    • The sampling cycle can be paused and manually adjusted, or saved and restarted.
    • Create summary descriptions that include tables and charts.
    • Algorithm trace records can be saved as plain text, pickles,sqlite or MySQL database documents or HDF5 documents.
    • Some methods of convergence diagnosis are provided.
    • Extensibility: Introduce a custom step method and an unconventional probability distribution.
    • MCMC loops can be embedded in larger programs, and the results can be analyzed using Python.
Installation

PYMC can be run on Mac OS X,linux and Windows systems. Installing some other pre-assembled libraries can increase the performance and functionality of the PYMC more significantly.

Pre-assembled libraries

The operation of PYMC requires the installation and configuration of some pre-assembled libraries.

    • Version Python2.6 and above
    • NumPy (version 1.6 and above)
    • Matplotlib (version 1.0 and above)
    • SciPy (optional)
    • Pytables (optional)
    • Pydot (optional)
    • IPython (optional)
    • Nose (optional)
Installing with Easyinstall

The simplest way to install PYMC is to enter the following code in the terminal:

Make sure that the user has the appropriate permissions to install.

Installing using precompiled binaries
    1. Download the installer from PyPI.
    2. Double-click the executable installation package and follow the wizard to install it.
Compile source Installation

The user can download the source code and unzip it from the GitHub download page.

Installing from GitHub

Users can find PYMC in GitHub and do the following:

The historical version /tags can be found in the catalog.

Executing a test suite

pymcContains a test case to ensure that key components in your code work correctly. Before running this test, the user needs to ensure that nose is already installed locally, executing the following code in the Python compiler:

If the test fails, the specific information for the error is displayed.

Use

First, define your model in the file and name it mymodel.py.

Save this file and call it in the Python compiler or other files in the same directory:

This example will produce 10,000 post-test samples. This sample is stored in the Python serialization database.

Tutorial examples

Tutorials Guide users through common PYMC applications.

How to fit a model with MCMC

PYMC provides some methods to fit a probabilistic model. The most important fitting model method is the MCMC Marcof Montecalo algorithm. Generate an MCMC object to process our model, import disaster_model.py it and take it as a MCMC parameter.

Call the method in MCMC sample() (or the interactive sampling function isample() ) to run the sampler:

After waiting a few seconds, you can see that the sampling process is complete and the model has finished fitting.

Add QQ group 813622576 or Vx;tanzhouyiwean free to receive Python learning materials

PYMC: Markov chain Monte Carlo sampling tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.