Skip to content

Instantly share code, notes, and snippets.

View fritzo's full-sized avatar

Fritz Obermeyer fritzo

View GitHub Profile
@fritzo
fritzo / model.py
Created December 13, 2018 16:20
Vectorized conditional in Pyro
# This faster version uses a vectorized pyro.plate and pyro.mask
# to perform vectorized inference.
def vectorized_model(x, y, truncated):
rate = my_regression_function(x)
y_dist = dist.Exponential(rate)
with pyro.plate("data", len(x)):
with pyro.mask(~truncated):
pyro.sample("obs", y_dist, obs=y)
with pyro.mask(truncated):
pyro.sample("truncated_obs",
@fritzo
fritzo / gist:c0bf6727ca71a9d3f684
Last active August 29, 2015 14:05
Three main ways puddle uses puddle-syntax
// 1. render a line from the corpus
var line = ...from corpus...
var term = syntax.compiler.load(line);
var renderableTerm = syntax.compiler.parenthesize(term);
...render renderableTerm via angular...
// 2. move the cursor to a line
var cursor = ...global...
var line = ...from corpus...
var term = syntax.compiler.load(line);
@fritzo
fritzo / gist:8837722
Last active August 29, 2015 13:56
Pomagma critique
  • compiler.js is very complex
    • can rendering be pulled out?
    • can it be ignorant of line names, ASSERT, DEFINE?
  • analyst.js and analyst_worker.js are unused
  • editor.js is too complex
    • maybe factor out validity polling
  • navigate.js needs a description, what does it do?
    • how could it be made more general?
  • switch to CommonJS module format
  • factor sync out of corpus.js
@fritzo
fritzo / gist:3138949
Last active October 7, 2015 08:58
Add unlikely() and likely() wrappers in gnu C++
/* from the cython compiler */
#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x) (x)
#define unlikely(x) (x)