Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve README #71

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
# nutpie: A fast sampler for bayesian posteriors
# nutpie: A fast sampler for Bayesian posteriors

## Installation

nutpie can be installed using conda or mamba from conda-forge with
nutpie can be installed using Conda or Mamba from conda-forge with

```
```bash
mamba install -c conda-forge nutpie pymc
```

Or using pip:

```
```bash
pip install nutpie
```

To install it from source, install a rust compiler and maturin and then
To install it from source, install a Rust compiler and maturin and then

```
```bash
maturin develop --release
```

If you want to use the nightly simd implementation for some of the math functions,
switch to rust nightly and then install with the `simd_support` feature in then
If you want to use the nightly SIMD implementation for some of the math functions,
switch to Rust nightly and then install with the `simd_support` feature in then
nutpie directory:

```
```bash
rustup override set nightly
maturin develop --release --features=simd_support
```

## Usage with PyMC

First, PyMC and numba need to be installed, for example using
First, PyMC and Numba need to be installed, for example using

```
```bash
mamba install pymc numba
```

Expand Down Expand Up @@ -91,31 +91,31 @@ compiled_model = nutpie.compile_pymc_model(pymc_model)
trace_pymc = nutpie.sample(compiled_model)
```

`trace_pymc` now contains an arviz `InferenceData` object, including sampling
`trace_pymc` now contains an ArviZ `InferenceData` object, including sampling
statistics and the posterior of the variables defined above.

## Usage with Stan

In order to sample from stan model, `bridgestan` needs to be installed.
A pip package is available, but right now this can not be installed using conda.
In order to sample from Stan model, `bridgestan` needs to be installed.
A pip package is available, but right now this can not be installed using Conda.

```
```bash
pip install bridgestan
```

When we install nutpie with pip, we can also specify that we want optional
dependencies for Stan models using

```
```bash
pip install 'bridgestan[stan]'
```

In addition, a C++ compiler needs to be available. For details see
[the stan docs](https://mc-stan.org/docs/cmdstan-guide/cmdstan-installation.html#cpp-toolchain).
[the Stan docs](https://mc-stan.org/docs/cmdstan-guide/cmdstan-installation.html#cpp-toolchain).

We can then compile a Stan model, and sample using nutpie:

```
```python
import nutpie

code = """
Expand All @@ -138,7 +138,7 @@ trace = nutpie.sample(compiled)

## Advantages

nutpie uses [`nuts-rs`](https://github.com/pymc-devs/nuts-rs), a library written in rust, that implements NUTS as in
pymc and stan, but with a slightly different mass matrix tuning method as
nutpie uses [`nuts-rs`](https://github.com/pymc-devs/nuts-rs), a library written in Rust, that implements NUTS as in
PyMC and Stan, but with a slightly different mass matrix tuning method as
those. It often produces a higher effective sample size per gradient
evaluation, and tends to converge faster and with fewer gradient evaluation.