Skip to content

Instantly share code, notes, and snippets.

@yurivish
yurivish / Treap.jl
Last active August 29, 2015 14:01
A Julia implementation of a treap (v6; in progress)
import Base: isempty, start, next, done, length, getindex, minimum, maximum, search, show
export Treap, TreapNode
type TreapNode{K}
priority::Float64
size::Int
key::K
left::TreapNode{K}
right::TreapNode{K}
@owainlewis
owainlewis / Treap.hs
Created December 11, 2013 22:07
Treap in Haskell
import Control.Monad
import Data.Char
import qualified Data.List.Key as K
import System.Random
data Treap k a = Nil | Node Int k a (Treap k a) (Treap k a)
priority :: Treap k a -> Int
priority Nil = -1
priority (Node p _ _ _ _) = p
@sbos
sbos / HMM.jl
Created November 1, 2013 11:25
Hidden Markov Model in Julia
module HMM
using Distributions
import Distributions.rand
import Distributions.fit
immutable HiddenMarkovModel{TP, K}
theta::Vector{TP}
A::Matrix{Float64}
@lqdc
lqdc / viterbi.jl
Created April 24, 2013 04:44
Viterbi implementation in Julia Language
# Author: Roman Sinayev
# License: BSD Style.
# Viterbi algorithm implementation and example written in Julia Language
#
# The idea is to decode the most probable order of a hidden markov model
# based on indirect observations.
# In the example below, we attempt to determine where a person is based on
# their cell phone service strength. We also have fake probabilities associated
# with each state(location) and with transitions between locations and with
@dvanhorn
dvanhorn / 0cfa-church.rkt
Created October 3, 2012 06:23
0CFA in the AAM style on some hairy Church numeral churning
#lang racket
;; 0CFA in the AAM style on some hairy Church numeral churning
;; Moral: per machine-state store polyvariance is not viable,
;; but with widening it's not so bad.
;; (X -> Set X) -> (Set X) -> (Set X)
(define ((appl f) s)
(for/fold ([i (set)])