Instantly share code, notes, and snippets.

• Sort options
Last active Nov 20, 2018
View zoo
 // // Zoo: Infer prevalence of 3 animals after a zoo visit // // Observed: 3 lions, 2 tigers and 1 bear // // Questions: // - Prevalence of each species // - Probability of seeing a bear next time //
Last active Oct 25, 2018
View game_of_ur
 // // Game of Ur // var roll = function() { return flip() + flip() + flip() + flip(); } var game = function() { var n = sample(RandomInteger({n: 20}));
Last active Oct 11, 2018
View second_tallest
 var person = function() { var is_female = sample(Bernoulli({p: 0.51})) if (is_female == false) { return {hgt: sample(Gaussian({mu: 178.0, sigma: 7.7})), is_female: is_female} } else { return {hgt: sample(Gaussian({mu: 163.0, sigma: 7.3})), is_female: is_female} } } var is_taller = function(h1, h2) {
Last active Sep 15, 2018
View four_dice.wppl
 // 4 dice: 4, 6, 8 and 12 sides // each dice is perfect var dice = [ Categorical( { ps: [1/4, 1/4, 1/4, 1/4], vs: [0, 1, 2, 3] } ), Categorical(
Last active Aug 26, 2018
Agentmodels, WebPPL: Monty Hall Example
View monty.wppl
 // Remove each element in array ys from array xs var remove = function(xs, ys) { return _.without.apply(null, [xs].concat(ys)); }; var doors = [1, 2, 3]; // Monty chooses a door that is neither Alice's door // nor the prize door var monty = function(aliceDoor, prizeDoor) {
Last active Jul 9, 2019
SoftRank: from scores to rank distributions
View softrank_distribution
 """ Demo script to compute rank distributions given pairwise preference probabilities. Data: - pairwise preference probabilities (not including self) Output: - distribution over ranks Michael Taylor, John Guiver, Stephen Robertson and Tom Minka, "SoftRank: Optimising Non-Smooth Rank Metrics", WSDM 2008.
Created Dec 6, 2017 — forked from mblondel/letor_metrics.py
Learning to rank metrics.
View letor_metrics.py
 # (C) Mathieu Blondel, November 2013 # License: BSD 3 clause import numpy as np def ranking_precision_score(y_true, y_score, k=10): """Precision at rank k Parameters
Created Nov 26, 2017
View IntervalSort
 """ Class to sort intervals. A collection of intervals is sorted: (1) in increasing order by start index (2) in increasing order by end index Sample data: data = [(1, 2), (0, 1), (0, 3), (5, 9), (1, 4), (1, 2), (2, 5), (5, 8), (3, 6)] """
Created Nov 25, 2017
View SegmentTiler
 """ Class to pack or tile segments. Example data: data = [ (0, 1), (0, 2), (0, 3), (1, 3), (2, 4), (0, 5) ] NB: sorted segments are expected (cf. IntervalSort)! """
Created Jan 26, 2017 — forked from AustinRochford/dataphilly-jul2016.ipynb
DataPhilly July 2016 Introduction to Probabilistic Programming
View dataphilly-jul2016.ipynb