Skip to main content

Magics for defining stan code in notebooks.

Project description


jupyterstan is a package to help development of Stan models (using pystan) in jupyter notebooks.

The package is heavily based on Arvinds-ds stanmagic package, but provides an interface that simply returns a pystan.Model object.

In addition, it bundles Arvinds-ds stan_code_helper package to improve syntax highlighting for stan cells.


To install the library:

pip install jupyterstan


To use the magic in your notebook, you need to lead the extension:

%load_ext jupyterstan

To define a stan model inside a jupyter notebook, start a cell with the %%stan magic. You can also provide a variable name, which is the variable name that the pystan.Model object will be assigned to. For example:

%%stan paris_female_births
data {
    int male;
    int female;

parameters {
    real<lower=0, upper=1> p;

model {
    female ~ binomial(male + female, p);

Then, to use your defined model:

fit = paris_female_births.sampling(
    data={'male': 251527, 'female': 241945},

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

jupyterstan-0.1.3.tar.gz (11.6 kB view hashes)

Uploaded source

Built Distribution

jupyterstan-0.1.3-py2.py3-none-any.whl (13.2 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page