Skip to content

Instantly share code, notes, and snippets.

Avatar

Giles Van Gruisen gilesvangruisen

View GitHub Profile
View hdi.py
def _highest_density_interval(self, pmf, p=.9, title=''):
# If we pass a DataFrame, just call this recursively on the columns
if(isinstance(pmf, pd.DataFrame)):
return pd.DataFrame([self._highest_density_interval(pmf[col], title=str(col)) for col in pmf],
index=pmf.columns)
# Broadcast the probability distribution to an artificial set of samples by
# repeating each index value N times where N = probability sample_precision
sample_precision = 1000000
samples_repeats = np.array(pmf.values * sample_precision)#.astype(int)
@gilesvangruisen
gilesvangruisen / ci.yml
Created Apr 5, 2020
Ruby/Rails GitHub Actions CI
View ci.yml
name: rspec
on:
pull_request:
branches:
- "master"
push:
branches:
- "master"
View gist:fa420482762b216b2cf934c4ee350bba
Start Date,End Date,# Days,Location
12/30/2014,1/1/2015,2,"Quechee, VT"
1/1/2015,1/4/2015,3,"Newport, RI"
1/4/2015,1/13/2015,9,"Somerville, MA"
1/13/2015,1/17/2015,4,"San Francisco, CA"
1/18/2015,1/22/2015,4,"Somerville, MA"
1/22/2015,1/27/2015,5,"Newport, RI"
1/27/2015,2/7/2015,11,"Somerville, MA"
2/7/2015,2/8/2015,1,"Newport, RI"
2/8/2015,2/18/2015,10,"Somerville, MA"
@gilesvangruisen
gilesvangruisen / LocalStore.swift
Last active Aug 29, 2015
StorableValue protocol for encoding/decoding a value type and StoredValue object for boxing up a StorableValue to be cached. (Value types can't conform to NSCoding because it's a class-protocol.)
View LocalStore.swift
//
// LocalStore.swift
// FPAPI
//
// Created by Giles Van Gruisen on 3/23/15.
// Copyright (c) 2015 Remarkable.io. All rights reserved.
//
import Foundation
import AwesomeCache
View Pipeline.swift
infix operator --> { associativity left precedence 160 }
func --><T, S>(argument: T?, body: (T) -> (S)) -> S? {
if let value = argument {
return body(value) as S
} else {
return nil
}
}
@gilesvangruisen
gilesvangruisen / binarySearch
Last active Aug 29, 2015
Swift generic binary search
View binarySearch
// Binary search
func binarySearch<T: Comparable>(target: T, collection: [T]) -> Int {
var min = 0
var max = countElements(collection) - 1
return binaryMakeGuess(min, max, target, collection)
}
@gilesvangruisen
gilesvangruisen / Publisher.h
Last active Jun 10, 2020
Basic pub/sub with Objective-C
View Publisher.h
@interface Publisher : NSObject
- (void)subscribe:(void(^)(id object))subscriptionBlock;
- (void)publish:(id)object;
@end