BenXZhang / bridgestan

BridgeStan provides efficient in-memory access through Python, Julia, and R to the methods of a Stan model.

Home Page:https://roualdes.github.io/bridgestan

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BridgeStan

DOCS DOI CI

BridgeStan provides efficient in-memory access through Python, Julia, and R to the methods of a Stan model, including log densities, gradients, Hessians, and constraining and unconstraining transforms. The motivation was developing inference algorithms in higher-level languages for arbitrary Stan models.

Stan is a probabilistic programming language for coding statistical models. For an introduction to what can be coded in Stan, see the Stan User's Guide.

BridgeStan is currently shipping with Stan version 2.32.1

Documentation is available at https://roualdes.github.io/bridgestan/

Compatibility

BridgeStan has been tested with the following operating system and C++ compiler combinations.

  • Linux: Ubuntu 20.04 with gcc 9.4.0
  • Apple: Mac OS X 12.2 with Apple clang 11.0.3
  • Microsoft: Windows 10 with gcc MSYS2 5.3.0

Installing BridgeStan

Installing the core of BridgeStan is as simple as installing a C++ toolchain (libraries, compiler, and the make command), and downloading this repository. To download the latest development version, you can run

git clone --recurse-submodules https://github.com/roualdes/bridgestan.git

For a full guide on installing, configuring, and using BridgeStan, consult the documentation

Using BridgeStan

Compiling a Stan program

To compile the Stan model in test_models/multi/multi.stan to a binary shared object (.so file), use the following.

$ cd bridgestan
$ make test_models/multi/multi_model.so

This will require internet access the first time you run it in order to download the appropriate Stan compiler for your platform into <bridgestan-dir>/bin/stanc[.exe]

Example programs

This repository includes examples of calling Stan through BridgeStan in Python, Julia, R, and C.

Examples of other functionality can be found in the test folder for each interface.

Acknowledgements

The Julia and Python APIs were derived from the Stan Model Server API, which in turn was derived from ReddingStan.

Thanks to Sebastian Weber (GitHub @wds15) for enabling multi-threaded calls from Julia to a single Stan model instance.

About

BridgeStan provides efficient in-memory access through Python, Julia, and R to the methods of a Stan model.

https://roualdes.github.io/bridgestan

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 28.2%Language:Julia 21.0%Language:Rust 16.3%Language:C++ 14.0%Language:R 9.1%Language:C 7.5%Language:Makefile 2.4%Language:Stan 1.4%