Skip to content

Instantly share code, notes, and snippets.


Avi Bryant avibryant

  • Galiano Island, BC
View GitHub Profile
SystemOrganization addCategory: #'Diplomatik-Game'!
SystemOrganization addCategory: #'Diplomatik-Judge'!
SystemOrganization addCategory: #'Diplomatik-Users'!
SystemOrganization addCategory: #'Diplomatik-UI'!
WAComponent subclass: #DAdmin
instanceVariableNames: 'password'
classVariableNames: ''
poolDictionaries: ''
category: 'Diplomatik-UI'!

It had been 13 days since I'd found a spreader, and I was starting to get worried.

The last time my sero levels had been this low, I'd gone down to the arrivals level of the international terminal at the airport. I mean, obviously there wouldn't be any spreaders there unless someone screwed up the pre-flight screening. But they say that low viral loads of unfamiliar strains could still boost you in a pinch, so I scanned the room for the most exotic-looking passengers I could find and tried to cozy up to them. Once, I managed to lick the handles of a few suitcases going around the carousel without too many people noticing.

Anyway, I guess what they say is true, because my sero bounced up. But I think I got lucky; there's no substitute for prolonged contact with someone who's gone full sympto.

I texted my doctor again.

ffs you're literally killing me here

View gist:863ed4af96bd6db03f077d0cdb2a6f62
val a = Real.latent{a => a.mean(0) && a.stdDev(1)}
val b = Real.latent{b => b.mean(0) && b.stdDev(1)}
val xs: Seq[Double] = ???
val ys: Seq[Long] = ???
Model.observe(xs, ys){(x,y)=>
y.mean(a + x*b)
View Distributions2.scala
Positive.countAndRate(n, x)
View Distributions.scala
View risk.rb
attacker = ARGV[0].to_i
defender = ARGV[1].to_i
def roll(k, n)
while attacker > 0 && defender > 0
sleep 1
attacker_dice = [attacker, 3].min
View DensityPlot.scala
case class DensityPlot(
nRows: Int = 20,
nColumns: Int = 80,
xLabelWidth: Int = 9,
yLabelWidth: Int = 9,
yLabelEvery: Int = 5,
logX: Boolean = false,
logY: Boolean = false,
logMarkers: Boolean = false,
markers: String = "·∘⚬") {
View Broadcast.scala
//A type-level implementation of the broadcasting rules from NumPy,
//such that incompatible shapes are a compile-time error.
//see eg
//for more info on what the constraints this is enccoding
//Note: this is only the shape logic. It does not include,
//and is agnostic to, any particular multi-dimensional array implementation.
sealed trait Shape
sealed trait Dimension extends Shape

An idiosyncratic guide to teaching yourself practical machine learning, without links:

  • Find a binary classification dataset; maybe you have one internally.
  • Implement a simple decision tree algorithm, like CART.
  • Write some code to validate your model; produce an ROC curve and understand the tradeoff it embodies.
  • Compare the ROC for your training set with the ROC for a holdout and understand what it means that they differ.
  • Experiment with some hyperparameters: how does the comparison above change as you adjust the depth of the tree or other stopping criteria?
  • Combine your decision tree algorithm with bagging to produce a random forest. How does its ROC compare?
  • Do the same hyperparameter tuning here. (How many trees?) Reflect on overfitting and on the bias/variance tradeoff.
View gist:b2df11671f1a8e5099d7
def takeBy(pipe: TypedPipe[(K,V)], max: Int)(fn: V => Double): TypedPipe[(K,V)] = {
implicit val qtreeSemi = QTreeSemigroup(4) //magic number, determines how much RAM the trees take
val qtrees ={case (k,v) => k -> QTree(fn(v))}.sumByKey
val maxV = qtrees.flatMap{case (k,q) =>
if(q.size > max) {
val targetQuantile = max.toDouble / q.size
val (lower, upper) = q.quantileBounds(targetQuantile)
Some(k -> upper) //this will give us at least max values; use lower to get at most max values