Skip to content

Instantly share code, notes, and snippets.

cberzan /
Created May 18, 2018
# Supporting code for this blog article:
# License: public domain.
import itertools
import numpy as np
def pretty_print_matrix(name, M):
cberzan / gist:f4a7a32cae69ba5380fd
Last active Aug 14, 2017
utils for handling recently downloaded files
View gist:f4a7a32cae69ba5380fd
# Utils for handling files in ~/Downloads:
function lsdl() {
ls --color -1 -t "$DOWNLOADS_DIR" |head |nl
function cpdl() {
if [ "a$1" == 'a-h' ] || [ "a$1" == 'a--help' ]; then
View PCFG.scala
import com.cra.figaro.language._
import com.cra.figaro.library._
import com.cra.figaro.library.compound._
import com.cra.figaro.algorithm.sampling._
import scala.math
object Node extends Enumeration {
type Node = Value
cberzan /
Created Nov 1, 2012
quick hack: turn a bunch of images into a video slideshow
# Takes all images given as parameters, and makes a video slideshow out of them.
# Note that the images are ordered lexicographically, regardless of the order in
# which they are given.
# Output Parameters:
cberzan /
Created Mar 14, 2015
coding quiz for Planet Labs
#!/usr/bin/env python
# Find anagram groups in the given dictionary file.
# Example usage: ./ /usr/share/dict/words
# The input file must have one word per line. We do not do any
# preprocessing, like lowercasing or removing punctuation.
# The output (stdout) contains one anagram group per line.
cberzan /
Created Feb 3, 2015 2015-02-03
// Dynamics model:
// Car parameters:
random Real car_a ~ DontCare();
random Real car_b ~ DontCare();
random Real car_h ~ DontCare();
random Real car_L ~ DontCare();
// Initial car pose:
View gist:c0d5b0aab44c5e26f6ca
Error Examples
View gist:21268389f11efd1a8cf6
../example/ Number expression expecting implicit set
java.lang.IllegalArgumentException: The mean given is not a valid row vector. It has dimensions 2 by 1. at blog.distrib.MultivarGaussian.setParams( at blog.distrib.MultivarGaussian.setParams( at blog.model.DistribSpec.initCPD( at blog.model.DistribSpec.compile( at blog.model.DependencyModel.compile( at blog.model.RandomFunction.compile( at blog.model.Model.compile( at blog.Main.setup( at blog.Main.main( Error initializing CPD at 21: couldn't instantiate class class blog.distrib.MultivarGaussian Encountered 1 errors in compilation phase.
../example/ Number expression expecting implicit set (no location): Symbol "B1" is neither a variable in th
cberzan / gist:cb3fb12f9ba3ab56da67
Last active Aug 29, 2015
mockup of how the repl might work
View gist:cb3fb12f9ba3ab56da67
// BLOG use case: Want some burn-in samples at the beginning of the run.
model = new Model.fromFile("")
evidence = new Evidence()
queries = new List()
sampler = new blog.sample.MHSampler(model, evidence, queries)
engine = new blog.engine.SamplingEngine(sampler)
// Burn-in: Since no queries are set yet, no results are recorded.
cberzan / benchmark
Created Jun 3, 2014
benchmark cost of checking boolean flags on every call
View benchmark
import java.util.Random;
public class Benchmark {
public Benchmark() {
rng = new Random();
hasLower = false;
hasUpper = false;
public void setParams(Double lower, Double upper) {