Created
July 24, 2020 19:04
-
-
Save ckrapu/9dd76adac024363cffe5649dae1ca347 to your computer and use it in GitHub Desktop.
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
import pymc3 as pm | |
from time import time | |
traces = [] | |
t1 = time() | |
with pm.Model() as model: | |
RVS = [] | |
for i in range(20): | |
RVS.append(pm.Normal('var_{0}'.format(i))) | |
traces.append(pm.sample()) | |
t2 = time() | |
with pm.Model() as model: | |
var = pm.Normal('var',shape=20) | |
traces.append(pm.sample()) | |
t3 = time() | |
times = [t2-t1, t3-t2] | |
labels = ['separate','concatenated'] | |
for t, l, trace in zip(times, labels, traces): | |
min_ess = pm.summary(trace)['ess_mean'].min() | |
ess_rate = int(min_ess/t) | |
print('For {0} variables case, the lowest effective sampling rate was {1} samples/second'.format(l,ess_rate)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment