This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools as it | |
def credible_interval(lims, ys, mass=0.95): | |
dimensions = ys.shape | |
coordinates = it.product(*(range(x) for x in dimensions)) | |
indexed = zip(ys.ravel(), coordinates) | |
indexed.sort(reverse=True) | |
acc = 0 | |
points = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def credible_interval(xlim, ys, mass=0.95): | |
"""Given a range, like (0, 20), and the y values for the probability density function, | |
returns the set of intervals spanning the minimum range to sum up to the mass.""" | |
indexed = zip(ys, range(len(ys))) | |
indexed.sort(reverse=True) | |
acc = 0 | |
points = [] | |
for (y, x) in indexed: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:81659fa1c5798695fc0314608dd01cc56859a4ebdbb2b1992d89db60ecb7e470" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns constraint-test | |
(:use [midje.sweet]) | |
(:require [datomic.api :as d])) | |
(def db-uri "datomic:mem://bug-test") | |
(def conn nil) | |
(defn setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import base64 | |
import hmac | |
import time | |
def _decrypt_cookie(name, value, cookie_secret, include_name=True): | |
def _cookie_signature(*parts): | |
hash = hmac.new(cookie_secret, | |
digestmod=hashlib.sha1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Internally defining MultiMap fails on compilation with the error | |
;;; | |
;;; error: java.lang.VerifyError: (class: multi-map/PersistentMultiMap, method: equiv signature: | |
;;; (Ljava/lang/Object;)Z) Expecting to find integer on stack (multi_map.clj:0) | |
;;; | |
(ns multi-map | |
(:refer-clojure :exclude [count assoc empty cons seq]) | |
(:require [clojure.set :as set]) | |
(:import clojure.lang.MapEntry java.util.Map)) |