Skip to content

Instantly share code, notes, and snippets.

@zaxtax
Created March 30, 2024 14:13
Show Gist options
  • Save zaxtax/a1e07f2d8dabf0a791776eb88cf80b8c to your computer and use it in GitHub Desktop.
Save zaxtax/a1e07f2d8dabf0a791776eb88cf80b8c to your computer and use it in GitHub Desktop.
LN-CASS prior implementation in pymc
# Implementation of the logit-normal continuous analogue of the spike-and-slab (LN-CASS) prior
# From https://royalsocietypublishing.org/doi/full/10.1098/rsif.2018.0572
import pymc as pm
import numpy as np
import matplotlib.pyplot as plt
mu = 0
tau = 5
sigma = 10
with pm.Model() as m:
lam = pm.LogitNormal("lam", mu, sigma)
x = pm.Normal("x", sigma=lam * tau)
with m:
samples = pm.draw(x, 10000)
plt.hist(samples, bins=50, rwidth=0.9, density=True, align='mid')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment