Skip to content

Instantly share code, notes, and snippets.

View lucianopaz's full-sized avatar
🇦🇷

Luciano Paz lucianopaz

🇦🇷
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lucianopaz
lucianopaz / vectorized_sample_ppc.py
Created July 16, 2019 10:40
An alternative implementation of `sample_posterior_predictive`, which relies on a vectorized call of `draw_values`.
def sample_posterior_predictive(trace,
samples: Optional[int]=None,
model: Optional[Model]=None,
vars: Optional[TIterable[Tensor]]=None,
var_names: Optional[List[str]]=None,
size: Optional[int]=None,
keep_size: Optional[bool]=False,
random_seed=None,
progressbar: bool=True) -> Dict[str, np.ndarray]:
"""Generate posterior predictive samples from a model given a trace.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lucianopaz
lucianopaz / Windows broken pipe.ipynb
Created November 27, 2018 16:41
Notebook that gets a BrokenPipeError raised on windows. Sometimes, this is caused because the multiprocessing backend in windows creates an entirely new process instead of forking it, so it needs an if __name__ == "__main__" statement that encloses the process pool
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lucianopaz
lucianopaz / test_pymc3_custom_distribution.py
Last active March 14, 2018 14:15
Creates a custom distribution and shows how draw_values fails for transformed RVs
from __future__ import print_function, unicode_literals, division, absolute_import
import theano as tt
import pymc3 as pm
from scipy import stats
import sys, traceback
class Foo(pm.Continuous):
def __init__(self, a, b):
self.a = tt.tensor.as_tensor_variable(a)
self.b = tt.tensor.as_tensor_variable(b)