Skip to content

Instantly share code, notes, and snippets.

View samvaughan's full-sized avatar

Sam Vaughan samvaughan

View GitHub Profile
@samvaughan
samvaughan / sparse.py
Created August 30, 2018 17:01
PyMC3 code to perform Sparse Bayes Regression (a translation of the Stan Code from https://betanalpha.github.io/assets/case_studies/bayes_sparse_regression.html)
import numpy as np
import pymc3 as pm
import matplotlib.pyplot as plt
"""
We have a situation where we have something we want to predict (y) and many variables y might depend on (200). We have 100 observations of each variable. We choose that y depends linearly on the data, with slope beta and offset alpha. Only some of the slopes are meaningful (different from 0).Can we recover these values of alpha and beta?
A PyMC3 translation of the Stan code from https://betanalpha.github.io/assets/case_studies/bayes_sparse_regression.html
"""