Skip to content

Instantly share code, notes, and snippets.

Avatar

Zack M. Davis zackmdavis

View GitHub Profile
@zackmdavis
zackmdavis / blegg.py
Last active Jan 8, 2021
calculations for "Unnatural Categories Are Optimized for Deception"
View blegg.py
from fractions import Fraction
from math import sqrt
def expected_squared_error(distribution, metric):
"""
If we know the distribution, and we "guess" the value of a sample from that
distribution, how much will we be wrong on average (with respect to a given
metric on the space, squared)?
"""
@zackmdavis
zackmdavis / message_length.rs
Created Oct 20, 2020
Rust source code for exposition of Minimum Description Length model selection for Markov chains
View message_length.rs
#!/usr/bin/env run-cargo-script
// cargo-deps: rand="0.7"
// Use cargo-script (https://github.com/DanielKeep/cargo-script) to run as a
// standalone script.
extern crate rand;
use std::collections::HashMap;
@zackmdavis
zackmdavis / slate_starchive.py
Last active Jun 30, 2020
replace links to Slate Star Codex posts with the last Internet Archive Wayback Machine version
View slate_starchive.py
import os
import re
import requests
import sys
slate_sturl_regex = re.compile(r"https?://slatestarcodex.com/\d{4}/\d{2}/\d{2}/[-a-z0-9]+/")
def slate_starchive_post_content(content):
@zackmdavis
zackmdavis / learning_to_signal.rs
Last active Jun 8, 2020
Rust source code for "Basics of the Evolution of Meaning" sender–receiver game
View learning_to_signal.rs
#!/usr/bin/env run-cargo-script
// cargo-deps: rand="0.7"
// Use cargo-script (https://github.com/DanielKeep/cargo-script) to run as a
// standalone script.
use std::collections::HashMap;
extern crate rand;
use rand::distributions::{Distribution, Uniform};
@zackmdavis
zackmdavis / factions.py
Created May 20, 2020
Python 3 source code for "Endogenous Epistemic Factionalization" replication/commentary
View factions.py
# Graphing requirements: scipy and matplotlib
import random
from math import factorial, sqrt
ε = 0.01 # size of edge for B
def binomial(p, n, k):
View log_score_vox.py
# https://www.vox.com/future-perfect/2020/1/7/21051910/predictions-trump-brexit-recession-2019-2020
from math import log2 as lg
predictions = [
# summary, probability, outcome
("Trump in office", 0.9, True),
("No Dem frontrunner", 0.6, False),
("No US recession", 0.8, True),
("No border wall", 0.95, True),
@zackmdavis
zackmdavis / comments.md
Created Nov 30, 2019
comments on "Seeking Power is Provably Instrumentally Convergent in MDPs"
View comments.md

(Thinking-out-loud comments on a not-yet-published draft.)

three choices: eat candy, eat chocolate, or hug a friend

(Some authors would consider chocolate a kind of candy?)

by generating triples in [0,1] here

"Here" links are terrible!

@zackmdavis
zackmdavis / last_friday_night.md
Last active Nov 13, 2019
Last Friday Night (Coalition Edition)
View last_friday_night.md

There's a claimant on the line
There's a regulator's fine
Brokers scream on Intercom
BD responds with aplomb
Integrate my CDF
And template that PDF
Running Docker in a chroot
Popping jobs off of the queue

Pictures of this spree

View univariate_fallacy_diagram.py
import functools
import itertools
import matplotlib.pyplot as plot
from matplotlib.colors import ListedColormap
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from numpy import array
from numpy.random import normal
from sklearn import svm
View bolding.py
import sys
import re
import logging
logging.basicConfig(level=logging.INFO)
terms = ["application", "breach notice law", "breach response costs", "business interruption loss", "claim", "claim expenses", "computer systems", "continuity date", "crisis management costs", "cyber extortion", "cyber extortion expenses", "cyber terrorism", "damages", "data breach", "denial of service attack", "digital asset", "employee", "extra expenses", "funds transfer fraud", "funds transfer loss", "incident", "indemnity period", "you", "your", "loss", "malicious code", "media content", "merchant service agreement", "multimedia wrongful act", "named insured", "pci fines and assessments", "personally identifiable information", "policy period", "pollutants", "privacy liability", "privacy policy", "public relations event", "ransomware", "regulatory penalties", "regulatory proceeding", "restoration costs", "retroactive date", "security failure", "senior executive", "service provider", "subsidiary", "systems failure", "third party