楼主: Nicolle
102 6

PyStan User's Guide [推广有奖]

版主

巨擘

0%

还不是VIP/贵宾

-

TA的文库  其他...

Python Programming

SAS Programming

Structural Equation Modeling

威望
15
论坛币
12197625 个
学术水平
2693 点
热心指数
2573 点
信用等级
2494 点
经验
411529 点
帖子
16674
精华
73
在线时间
6291 小时
注册时间
2005-4-23
最后登录
2018-2-25

Nicolle 学生认证  发表于 2018-2-14 23:23:01 |显示全部楼层
PyStan: The Python Interface to Stan

PyStan provides an interface to Stan, a package for Bayesian inference using the No-U-Turn sampler, a variant of Hamiltonian Monte Carlo.

License: Open source, GPL3

Documentation

Stan documentation
Important links
Similar projects
Indices and tables

本帖隐藏的内容

Pystan User's Guide.pdf (246.84 KB)




关键词:Guide STAN User guid GUI

支持楼主:购买VIP购买贵宾 购买后,论坛将奖励 10 元论坛资金给楼主,以表示您对TA发好贴的支持
 
载入中......

本帖被以下文库推荐

stata SPSS
Nicolle 学生认证  发表于 2018-2-14 23:24:26 |显示全部楼层
PyStan on Windows

PyStan is partially supported under Windows with the following caveats:

  • Python 3.5 or higher must be used.
  • When drawing samples n_jobs=1 must be used. (PyStan on Windows cannot use multiple processors in parallel.)
  • Vectorized functions are not supported with MSVC (see GCC section)

PyStan requires a working C++ compiler. Configuring such a compiler is typically the most challenging step in getting PyStan running.

Due to problems with MSVC template deduction, functions with Eigen library are failing. Until this bug is fixed no full support is provided for Windows + MSVC. Currently, no fix is known for this problem, other than to change the compiler to GCC.

Installing Python

There several ways of installing PyStan on Windows. The following instructions assume you have installed Python 3.5 (or higher) as packaged in the Anaconda Python distribution. (Make sure you install the Python 3 variant of Anaconda.) The Anaconda distribution is well-maintained and includes packages such as Numpy which PyStan requires. The following instructions assume that you are using Windows 7. (Windows 10 disregards user choice and user privacy.)


Installing a C++ Compiler

This section describes how to install the Microsoft Visual C++ 14.0 compiler. It is likely that PyStan will work with more recent Microsoft Visual C++ compilers as well.

Navigate to the Visual C++ Build Tools page and click on “Download Visual C++ Build Tools 2015”.

If you encounter problems you may find the Windows Compilers page on the Python Wiki useful. Note that on Windows 7 you may need to update the installed version of the Microsoft .NET Framework before installing the Visual C++ Build Tools.


Installing PyStan

Once you have the compiler installed, installing PyStan is easy. Open the application called “Command Prompt” (cmd.exe) and enter the following command:

pip install pystan

You can verify that everything was installed successfully by opening up the Python terminal (run python from a command prompt) and drawing samples from a very simple model:

>>> import pystan>>> model_code = 'parameters {real y;} model {y ~ normal(0,1);}'>>> model = pystan.StanModel(model_code=model_code)>>> y = model.sampling(n_jobs=1).extract()['y']>>> y.mean()  # with luck the result will be near 0

Again, remember that using n_jobs=1 when calling sampling is required as PyStan on Windows does not support sampling using multiple processors in parallel.


GCC on Windows

For full support of vectorized functions, the user must use GCC compiler.

Supported GCC compilers

  • Python 2.7 and <=3.4 : mingw32
  • Python 3.5=< : MSYS2 mingw-w64

For mingw32 installation see http://docs.cython.org/en/latest/src/tutorial/appendix.html

or with conda use:

conda install mingw32 libpython


Setting up mingw-w64 on Windows

Install Python with either Anaconda or Miniconda

Create an virtual conda-environment [OPTIONAL]:

conda create -n stan_env python=3.6

Activate conda-env [OPTIONAL]:

activate stan_env

Install libpython and m2w64-toolchain packages:

conda install libpythonconda install -c msys2 m2w64-toolchain

In PYTHONPATH\Lib\distutils create distutils.cfg with text editor (e.g. notepad, notepad++) and add the following lines:

[build]mingw32

To find the correct distutils path, run python:

>>> import distutils>>> print(distutils.__file__)

Finally, install other packages:

conda install numpy cython matplotlibpip install pystan



回复

使用道具 举报

hjtoh 发表于 2018-2-15 08:46:50 来自手机 |显示全部楼层
Nicolle 发表于 2018-2-14 23:23
PyStan: The Python Interface to StanPyStan provides an interface to Stan, a package for Bayesian inf ...
很给力
回复

使用道具 举报

albertwishedu 发表于 2018-2-15 13:49:50 |显示全部楼层
回复

使用道具 举报

tsangwm 发表于 2018-2-15 23:46:06 |显示全部楼层
谢谢分享
回复

使用道具 举报

qw789789 发表于 2018-2-16 07:45:15 |显示全部楼层
PyStan User's Guide

THX
回复

使用道具 举报

啸傲江弧 发表于 2018-2-16 14:15:28 |显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 我要注册

GMT+8, 2018-2-25 04:06