```
import sympy as sy
from IPython.display import display
sy.init_printing(use_latex='mathjax')
```


```
s, lambda_ = sy.symbols('s lambda', real=True, positive=True)
beta = sy.symbols('beta', real=True)
```

The gamma distribution: $\textrm{Gamma}(s_{ij}|1, \frac{\lambda^2}{2})$


```
gamma = lambda_**2/2 * sy.exp(-lambda_**2 / 2 * s)
display(gamma)
```


$$\frac{\lambda^{2}}{2 e^{\frac{\lambda^{2} s}{2}}}$$


The normal distribution: $\mathcal{N}(0, s_{ij}^2)$


```
normal = 1/s*sy.exp(-beta**2/2/s**2)
display(normal)
```


$$\frac{1}{s} e^{- \frac{\beta^{2}}{2 s^{2}}}$$



```
sy.simplify(normal * gamma)
```




$$\frac{\lambda^{2}}{2 s e^{\frac{\beta^{2}}{2 s^{2}} + \frac{\lambda^{2} s}{2}}}$$




```
sy.integrate(normal * gamma, s)
```




$$\int \frac{\lambda^{2} e^{- \frac{\beta^{2}}{2 s^{2}}}}{2 s e^{\frac{\lambda^{2} s}{2}}}\, ds$$




```
sy.expand_log(2 * sy.log(normal * gamma))
```




$$- \frac{\beta^{2}}{s^{2}} - \lambda^{2} s + 4 \log{\left (\lambda \right )} - 2 \log{\left (s \right )} - 2 \log{\left (2 \right )}$$



Draw from Laplacian prior given in wei_lap.stan (Peltola)


```
%matplotlib inline
import scipy.stats as st
import matplotlib.pyplot as plt
import numpy as np
N = 1000000
r1 = st.norm(0, 1).rvs(N)
r2 = st.gamma(.5, .5).rvs(N)
r = st.expon(1).rvs(N)
```


```
_ = plt.hist(r1)
```


```
_ = plt.hist(r2)
```


```
_ = plt.hist(r)
```


```
_ = plt.hist(r1 * np.sqrt(r/r2), bins=1000)
plt.xlim(-1.5, 1.5)
```


```

```

01e81a708594b02f52127ab31aa7ec97eb68acdc
ipynb
Jupyter Notebook
Laplace-prior.ipynb
JohnReid/sparse-decomp
6cc8fa9815b03224c09f386d79ba27036c3b40af
MIT
Laplace-prior.ipynb
JohnReid/sparse-decomp
6cc8fa9815b03224c09f386d79ba27036c3b40af
MIT
Laplace-prior.ipynb
JohnReid/sparse-decomp
6cc8fa9815b03224c09f386d79ba27036c3b40af
MIT
Qwen/Qwen-72B
1. YES
2. YES