Skip to content

Instantly share code, notes, and snippets.

View ajschumacher's full-sized avatar

Aaron Schumacher ajschumacher

View GitHub Profile
# oh my quiz
What the what?
: Option!
: Correct option! :
longest.ordered <- function(original) {
results <- list()
for (item in original) {
static_results <- results
for (stem in static_results) {
if (stem[length(stem)] <= item) {
results[[length(results)+1]] <- c(stem, item)
}
}
results[[length(results)+1]] <- item
@ajschumacher
ajschumacher / scoring.R
Created August 17, 2014 17:46
code for a blog post on Wilson scoring vs. Laplace smoothing
par(pty='s')
par(mfrow=c(1, 2))
ci_lower_bound <- function(pos, n, confidence) {
if (n == 0) return(0)
z = qnorm(1 - (1 - confidence) / 2)
p = pos / n
(p + z^2 / (2*n) - z * sqrt((p * (1-p) + z^2 / (4*n)) / n )) /
(1 + z^2 / n)
@ajschumacher
ajschumacher / build_logins.sh
Last active March 6, 2018 19:29 — forked from JoshData/build_logins.sh
script for making users for multi-user RStudio
#!/bin/bash
# Start an AWS instance with one of the AMIs provided by:
# http://www.louisaslett.com/RStudio_AMI/
#
# Get this script and make executable.
# wget THE_RAW_URL
# chmod +x build_logins.sh
#
# Then use this script to create many logins on the system.
@ajschumacher
ajschumacher / test.rst
Last active January 19, 2017 07:01
github fails to render rst email links properly
@ajschumacher
ajschumacher / getch.py
Created May 11, 2015 03:33
get one character at a time at the console with python
def _find_getch():
# courtesy of Louis
# http://stackoverflow.com/questions/510357/
try:
import termios
except ImportError:
# Non-POSIX. Return msvcrt's (Windows') getch.
import msvcrt
return msvcrt.getch
@ajschumacher
ajschumacher / README.md
Last active May 5, 2024 16:11 — forked from mbostock/.block
Interactive D3 view of sklearn decision tree
import tensorflow as tf
w = tf.Variable([2.0])
b = tf.Variable([2.0])
x = tf.constant([1.0])
y = tf.sigmoid(w*x + b)
y_ = tf.constant([0.0])
cross_entropy = -1*(y_*tf.log(y) + (1-y_)*(tf.log(1-y)))
s = tf.Session()
s.run(tf.initialize_all_variables())
@ajschumacher
ajschumacher / mspacman.py
Created January 12, 2017 22:27
play Ms. Pacman w/ OpenAI gym
import time
import pygame
import gym
frame_time = 1.0 / 15 # seconds
pygame.init()