Skip to content

Instantly share code, notes, and snippets.

Avatar

Zack M. Davis zackmdavis

View GitHub Profile
@zackmdavis
zackmdavis / vowel_swap_three_words.py
Last active Mar 27, 2022
words that are still words if you swap a vowel
View vowel_swap_three_words.py
from string import ascii_lowercase
def load_dictionary():
dictionary = set()
with open("/usr/share/dict/words") as dictionary_file:
for word in dictionary_file:
dictionary.add(word.strip())
return dictionary
VOWELS = ['a', 'e', 'i', 'o', 'u']
@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