Skip to content

A combination of utilities for PyStan both from Michael Betancourt's and Sean Talts Stan_utility as well as a few of my own

License

Notifications You must be signed in to change notification settings

grburgess/stan_utility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stan_utility

Utilities for PyStan for

  • caching model compilation in a smart way
  • caching sampling results in a smart way
  • checking Stan warnings
  • making corner plots of scalar parameters

Build Status PyPI version fury.io PyPI license

Install

$ pip install stan-utility

Usage

import stan_utility

model = stan_utility.compile_model('myscript.stan')
data = dict(mean=1)

results = stan_utility.sample_model(model, data, chains=2, iter=1000)
print(results.posterior)  ## a arviz.InferenceData object

# create mytest_fit_corner.pdf:
stan_utility.plot_corner(samples, outprefix="mytest_fit")

On the second run of this code,

  • compile_model will retrieve the compiled model from cache
  • sample_model will retrieve the results from cache. (change the seed or parameters if you want a fresh run).

Jupyter notebook features

See demos:

Editing the comments, adding and removing lines will not require recompilation of the model, because empty lines and comments are stripped out.

Contributors

Derived originally from Stan_utility by Michael Betancourt and Sean Talts.

  • @grburgess
  • @cescalara
  • @JohannesBuchner

Contributions are welcome.

About

A combination of utilities for PyStan both from Michael Betancourt's and Sean Talts Stan_utility as well as a few of my own

Resources

License

Stars

Watchers

Forks

Packages

No packages published