This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Estimate coin bias given multiple observations from adversarial experts. | |
# | |
import sys | |
import pymc3 as pm | |
import numpy as np | |
import theano.tensor as tt | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Attempt to implement Dawid-Skene model in PyMC3 (broken) | |
# | |
import pymc3 as pm | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import theano | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Attempt to implement Dawid-Skene model in PyMC3 (probably working) | |
# | |
import pymc3 as pm | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import theano | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import seaborn as sns | |
import pymc3 as pm | |
import numpy as np | |
from scipy.stats import norm | |
import pandas as pd | |
import theano.tensor as T | |
from theano.compile.ops import as_op | |
# Generate True data |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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)! | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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)] | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
OlderNewer