Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Making sense of Probabilistic Programming with Figaro and Pfennig
===
SlamData tech talk 2016-09-08
Building Interest
---
- Noticed Probabilistic Graphical Models on Coursera
- https://www.coursera.org/learn/probabilistic-graphical-models
- Probabilistic Graphical Models: Principles and Techniques (Adaptive Computation and Machine Learning series) by Daphne Koller (Author), Nir Friedman (Author)
@drostron
drostron / list-value-homogeneity-ocaml.ml
Last active August 29, 2015 14:01
list value homogeneity
let rec i j = match j with
| [] | [_] -> true
| a :: b :: c -> a = b && i(b::c);;
import scala.concurrent._, ExecutionContext.Implicits.global
import scala.async.Async.{async, await}
object AsyncExploration {
// hmm, monad transformers are cool and all but for this simple case async might be the winner
val α =
async {
for {
@drostron
drostron / slate.js
Last active August 29, 2015 14:00
my slate.js config (here for now til I get around to creating a dotfiles repo)
S.configAll({
"defaultToCurrentScreen" : true,
"secondsBetweenRepeat" : 0.05,
"checkDefaultsOnLoad" : true,
"focusCheckWidthMax" : 3000,
"windowHintsBackgroundColor" : [50, 53, 58, 0.73],
"windowHintsDuration" : 7,
"windowHintsWidth" : 65,
"windowHintsHeight" : 65,
"windowHintsFontSize" : 36
import shapeless._, Poly._
import scala.concurrent._, duration._, ExecutionContext.Implicits.global
object zoz extends Poly2 {
implicit def default[T, U] = at[T, T ⇒ U] { (acc, t) ⇒ t(acc) }
}
val f1 = (s: Future[String]) ⇒ s.map(1 :: _ :: HNil)
val f2 = (i: Future[Int :: String :: HNil]) ⇒ i.map(7L :: _)
val f3 = (l: Future[Long :: Int :: String :: HNil]) ⇒ l.map('z' :: _)
object TypeClassExample {
trait UnicodeOrdered[T] {
def ≤(i:T,j:T): Boolean
}
object UnicodeOrdered {
implicit object UnicodeOrderedInt extends UnicodeOrdered[Int] {
def ≤(i:Int,j:Int): Boolean = i <= j
}
@drostron
drostron / FocusOnScalaz.scala
Created July 16, 2013 17:36
a translation of the shapeless lens example to scalaz, https://github.com/milessabin/shapeless
import scalaz.Lens
object FocusOnScalaz {
// A pair of ordinary case classes ...
case class Address(street : String, city : String, postcode : String)
case class Person(name : String, age : Int, address : Address)
// Some lenses over Person/Address ...
val nameLens = Lens.lensu[Person, String]((u, newName) => u.copy(name = newName), _.name)
object Common {
trait I[A, B] {
def apply(a: A): B
}
def i[A, B](f: A => B): I[A, B] = new I[A,B] {
def apply(a: A) = f(a)
}
case class Z(boz: String)
@drostron
drostron / RandomGeneratorProjection.scala
Last active December 11, 2015 18:08
Random Generator Projection Exploration
import util.Random
object RandomGeneratorProjection {
// in : size of the input generator
// out : size of the output generator
def d(in: Int, out: Int): Int = {
assert(in > 1, "in must be greater than 1")
assert(out > 0, "out must be greater than 0")