Skip to main content

decentralise

Build Status codecov

Make (some) Stan programs non-centered automatically.

Inspired by reading this paper.

Installation

Requires python 3.6+. Install with pip:

pip install decentralise

Example

This package provides a command line tool: decentralise, which is used as follows:

decentralise <input-file> <output-destination>

It will take any normally distributed parameters that have variances that are themselves parameters, and reparameterise them to make them non-centered. For example, the canonical eight schools code is:

data {
  int<lower=0> J; // number of schools
  vector[J] y; // estimated treatment effects
  vector<lower=0>[J] sigma; // s.e. of effect estimates
}
parameters {
  real mu;
  real<lower=0> tau;
  vector[J] theta;
}
model {
  theta ~ normal(mu, tau);
  y ~ normal(theta, sigma);
}

Once decentralise is applied, this program becomes

data {
  int<lower=0> J; // number of schools
  vector[J] y; // estimated treatment effects
  vector<lower=0>[J] sigma; // s.e. of effect estimates
}
parameters {
  real mu;
  real<lower=0> tau;
  vector[J] theta_std;
}
transformed parameters {
  vector[J] theta = mu + theta_std * tau;
}
model {
  theta_std ~ normal(0, 1);
  y ~ normal(theta, sigma);
}

I wrote this tool for fun, and have not thoroughly tested it. For example, it will fail for any parameters whose sampling statements are not vectorised. e.g.:

x ~ normal(mu, tau);

will work, but

for i in (1:n) {
    x[i] ~ normal(mu, tau);
}

will not. There are probably a ton of other cases where it will break that I have not anticipated, as well!

Metadata

Release files for decentralise 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for decentralise 0.0.1
File Size Uploaded Provenance Actions
decentralise-0.0.1.tar.gz 6.7 kB Without provenance Details for decentralise-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for decentralise 0.0.1
File Interpreter ABI Platform Actions
decentralise-0.0.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for decentralise-0.0.1-py2.py3-none-any.whl

Total release size: 11.7 kB

Release files / decentralise-0.0.1.tar.gz

Download URL decentralise-0.0.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3b791d798a6da86aa0971f58ff6ebd6d6f385a58bd0c965937da7c573d63cfac
BLAKE2b-256 checksum
How to use checksums
d42ea091da9ec70d8dacaea91be8aac0f64d03f55d21cbd86d77ccacb08a7336
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

Release files / decentralise-0.0.1-py2.py3-none-any.whl

Download URL decentralise-0.0.1-py2.py3-none-any.whl
Size 5.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fcf3f3bd6d2099d1159eb4691324fdfdcc94ad7ed2da0705ea085666229a86e2
BLAKE2b-256 checksum
How to use checksums
dc8149be6aba7250c93124ba449218974c439e58a69384e249edf942c7790b3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

Security for decentralise 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page