Skip to content

Instantly share code, notes, and snippets.

@ckrapu
Created July 24, 2020 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckrapu/9dd76adac024363cffe5649dae1ca347 to your computer and use it in GitHub Desktop.
Save ckrapu/9dd76adac024363cffe5649dae1ca347 to your computer and use it in GitHub Desktop.
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