Skip to content

Instantly share code, notes, and snippets.

View tyleransom's full-sized avatar

Tyler Ransom tyleransom

View GitHub Profile
using BenchmarkTools
using Optim, NLSolversBase
function datagen(n=5500,k=13)
b = rand(k)
l = rand(2)
x = randn(n,k)
abil = randn(n,1)
vabil = randn(n,1)
sector = 1.0.*(rand(n,1).>0.8)
@tyleransom
tyleransom / gcc-5.4.0-install.sh
Last active January 11, 2024 05:47 — forked from jdhao/gcc-5.4.0-install.sh
The script will install GCC 5.4.0 on your CentOS 7 system, make sure you have root right.
echo "Downloading gcc source files..."
curl https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.bz2 -O
echo "extracting files..."
tar xvfj gcc-5.4.0.tar.bz2
echo "Installing dependencies..."
yum install gmp-devel mpfr-devel libmpc-devel
echo "Configure and install..."
@tyleransom
tyleransom / vim_crash_course.md
Created December 30, 2017 21:44 — forked from dmsul/vim_crash_course.md
Vim Crash Course

NOTE: Specific examples given for options, flags, commands variations, etc., are not comprehensive.

NORMAL MODE

Vim has 2 main "modes", that chance the behavior of all your keys. The default mode of Vim is Normal Mode and is mostly used for moving the cursor and navigating the current file.

Some important (or longer) commands begin with ":" and you will see the text you enter next at the bottom left of the screen.

:q[uit] - quit (the current window of) Vim. ("Window" here is internal to Vim, not if you have multiple OS-level windows of Vim open at once.)
:q! - force quit (if the current buffer has been changed since the last save)
:e[dit] {filename} - read file {filename} into a new buffer.

@tyleransom
tyleransom / nlf.R
Created December 30, 2017 21:34 — forked from paulgp/nlf.R
code for NFL analysis
pbp_2016 <- read_csv("~/Downloads/pbp_2016.csv")
a <- pbp_2016 %>% group_by(GameID, posteam) %>% summarize(top = sum(PlayTimeDiff), end_score = max(PosTeamScore, na.rm=TRUE), numplays = n()) %>% filter(posteam != "NA") %>% group_by(GameID) %>% mutate(teamNum = row_number()) %>% select(GameID, top, numplays, teamNum, end_score)
score <- a %>% select(GameID, teamNum, end_score) %>% spread(teamNum, end_score, sep="_")
numplays <- a %>% select(GameID, teamNum, numplays) %>% spread(teamNum, numplays, sep="_")
top <- a %>% select(GameID, teamNum, top) %>% spread(teamNum, top, sep="_")
colnames(top) <- c("GameID", "top_1", "top_2")
colnames(score) <- c("GameID", "score_1", "score_2")
colnames(numplays) <- c("GameID", "numplays_1", "numplays_2")
final <- inner_join(numplays,score, by="GameID") %>% inner_join(top, by="GameID") %>% mutate(winner_1 = as.integer(score_1 > score_2))