Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cs224
cs224 / 2018-03-22-gpy-gpflow-differences.ipynb
Created March 22, 2018 16:05
gpy delivers results that differ from gpflow
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cs224
cs224 / hausarbeit_stein.ipynb
Created December 9, 2017 09:15
using sympy for numeric calculations with arbitrary precision
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cs224
cs224 / 00_pymc3_mixture_experiments_shifted_gamma.py
Last active March 11, 2017 16:28
Experiments in implementing a PyMC3 mixture model with two shifted Gamma stributions
import numpy as np, pandas as pd, matplotlib.pyplot as plt, seaborn as sns
import scipy.stats as stats
from theano import tensor as tt
import pymc3 as pm
from pymc3.distributions.dist_math import bound, logpow, gammaln
from pymc3.distributions.distribution import draw_values, generate_samples
SEED = 5132290 # from random.org
np.random.seed(SEED)
@cs224
cs224 / pyjags_rain_sprinkler_grass_simple_bayesian_network.py
Last active October 27, 2022 17:57
Simple Bayesian Network via Monte Carlo Markov Chain in PyMC3
import math
import pyjags
import numpy as np
import pandas as pd
np.random.seed(0)
np.set_printoptions(precision=3)
def pyjags_trace():
@cs224
cs224 / CoIterator.java
Created September 20, 2014 14:53
Reimplementing the Matthias Mann Coroutine and CoIterator on top of Quasar.
package control.structures.continuations.quasarFiberChannelSameThread;
import java.io.Serializable;
import java.util.Iterator;
import java.util.NoSuchElementException;
import co.paralleluniverse.fibers.SuspendExecution;
import co.paralleluniverse.strands.Strand.State;
import co.paralleluniverse.strands.SuspendableCallable;
@cs224
cs224 / BasicXADataSourceUsageTest.java
Created August 12, 2014 07:50
BasicXADataSourceUsageTest for H2, HSQLDB and Derby
package xaresource;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@cs224
cs224 / incanter-join.clj
Created October 13, 2013 05:17
$join does not work if the 1st element in the second dataset does not have a corresponding element in the first dataset
(ns experiment.incanter
(:require [incanter.core :as i]))
(def join-dataset-1 (i/dataset [:id :vehicle-type]
[[1 "car"]
[2 "motor-bike"]
[3 "train"]]))
;;;(i/view join-dataset-1)
(def join-dataset-2 (i/dataset [:id :number-wheels]
;;; The solution relies on the following implementation of the partitions function:
;;; https://gist.github.com/ray1729/5830608
(defn partition-combination-sets [partition]
(let [partition (vec partition)
c (count partition)]
(for [i (range 1 (inc c))
combination (combinatorics/combinations (range c) i)]
;; the following (map partition combination) may be a bit confusing, because it does use the vector
;; defined above as a function and has nothing to do with the standard partition function of the clojure core language.
@cs224
cs224 / gist:4570937
Created January 19, 2013 05:38
How to query for dublet attributes across entities via datomic.
(defn datomic-group-fds-by-fd-id [fd-v & {:keys [id-fn] :or {id-fn :hash}}]
(q '[:find ?fd-id (into [] ?fd)
:in $fd-v
:where
[$fd-v ?fd ?fd-id]
]
(maps->rel fd-v [id-fn])))
(defn datomic-get-redundant-files [grouped-fds-by-fd-id & {:keys [id-fn] :or {id-fn :hash}}]
(q '[:find ?fd-v-g