Skip to content

Instantly share code, notes, and snippets.

@cberzan
cberzan / linear_algebra_game.py
Created May 18, 2018 04:39
linear_algebra_game.py
# Supporting code for this blog article:
# https://thirld.com/blog/2018/05/17/linear-algebra-solves-a-childhood-mystery/
#
# License: public domain.
import itertools
import numpy as np
def pretty_print_matrix(name, M):
@cberzan
cberzan / anagrams.py
Created March 14, 2015 17:27
coding quiz for Planet Labs
#!/usr/bin/env python
# Find anagram groups in the given dictionary file.
#
# Example usage: ./anagrams.py /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
cberzan / slam.blog
Created February 3, 2015 21:12
slam.blog 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:
@cberzan
cberzan / gist:f4a7a32cae69ba5380fd
Last active August 14, 2017 02:33
utils for handling recently downloaded files
# Utils for handling files in ~/Downloads:
DOWNLOADS_DIR="$HOME/Downloads"
function lsdl() {
ls --color -1 -t "$DOWNLOADS_DIR" |head |nl
}
function cpdl() {
if [ "a$1" == 'a-h' ] || [ "a$1" == 'a--help' ]; then
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
../example/galaxy.blog
../example/galaxy.blog::108.7: Number expression expecting implicit set
../example/infinite-GMM.blog
java.lang.IllegalArgumentException: The mean given is not a valid row vector. It has dimensions 2 by 1. at blog.distrib.MultivarGaussian.setParams(MultivarGaussian.java:89) at blog.distrib.MultivarGaussian.setParams(MultivarGaussian.java:70) at blog.model.DistribSpec.initCPD(DistribSpec.java:260) at blog.model.DistribSpec.compile(DistribSpec.java:192) at blog.model.DependencyModel.compile(DependencyModel.java:202) at blog.model.RandomFunction.compile(RandomFunction.java:127) at blog.model.Model.compile(Model.java:531) at blog.Main.setup(Main.java:472) at blog.Main.main(Main.java:152) Error initializing CPD at 21: couldn't instantiate class class blog.distrib.MultivarGaussian Encountered 1 errors in compilation phase.
../example/aircraft-position.blog
../example/aircraft-position.blog::26.7: Number expression expecting implicit set (no location): Symbol "B1" is neither a variable in th
@cberzan
cberzan / gist:c0d5b0aab44c5e26f6ca
Created June 28, 2014 00:24
errorExamples.txt
Error Examples
../example/galaxy.blog
../example/infinite-GMM.blog
../example/aircraft-position.blog
../example/solutions/simple-aircraft.blog
../example/sybil-attack-exp3.blog
../example/general-fixed-fun.blog
../example/balls/id-uncert-det.blog
../example/balls/id-uncert-noisy.blog
../example/multivar-gaussian-random-params/random-mu-fixed-sigma.blog
@cberzan
cberzan / gist:cb3fb12f9ba3ab56da67
Last active August 29, 2015 14:02
mockup of how the repl might work
//////////////////////////////////////////////////////////////////////////////
// BLOG use case: Want some burn-in samples at the beginning of the run.
model = new Model.fromFile("burglary.blog")
evidence = new Evidence()
evidence.addFromFile("burglary.evi")
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
cberzan / benchmark
Created June 3, 2014 22:25
benchmark cost of checking boolean flags on every call
import java.util.Random;
public class Benchmark {
public Benchmark() {
rng = new Random();
hasLower = false;
hasUpper = false;
}
public void setParams(Double lower, Double upper) {

Keybase proof

I hereby claim:

  • I am cberzan on github.
  • I am cberzan (https://keybase.io/cberzan) on keybase.
  • I have a public key whose fingerprint is FEEB 0FF1 D39A 1323 C732 323A D712 8D28 B3D8 0DA1

To claim this, I am signing this object: