Skip to content

Instantly share code, notes, and snippets.

View grinnbearit's full-sized avatar

Sidhant Godiwala grinnbearit

View GitHub Profile
@grinnbearit
grinnbearit / credible_interval_nd.py
Created October 7, 2015 13:22
Credible interval of n dimensional, unimodal distributions in Python
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 = []
@grinnbearit
grinnbearit / credible_interval.py
Last active September 20, 2021 19:34
Credible interval of 1 dimensional distributions in Python
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:
{
"metadata": {
"name": "",
"signature": "sha256:81659fa1c5798695fc0314608dd01cc56859a4ebdbb2b1992d89db60ecb7e470"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
(ns constraint-test
(:use [midje.sweet])
(:require [datomic.api :as d]))
(def db-uri "datomic:mem://bug-test")
(def conn nil)
(defn setup
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)
;;; 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))