Skip to content

Instantly share code, notes, and snippets.

View stephband's full-sized avatar

stephband stephband

View GitHub Profile
// Viterbi algorithm for finding hidden relationships
function Viterbi(data) {
var V = [{}];
var path = {};
// Initialize base cases (t == 0)
for(var i=0;i<data.states.length;i++) {
var state = data.states[i];
V[0][state] = data.start_probability[state] * data.emission_probability[state][data.observations[0]];
path[state] = [state];
@stephband
stephband / rAF.js
Created May 25, 2012 14:10 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@stephband
stephband / gist:955477
Created May 4, 2011 16:03 — forked from jakearchibald/gist:955241
OCD in action
.whatever {
-webkit-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
-moz-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
-o-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
}