Created
March 30, 2024 14:13
-
-
Save zaxtax/a1e07f2d8dabf0a791776eb88cf80b8c to your computer and use it in GitHub Desktop.
LN-CASS prior implementation in pymc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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