Skip to content

Instantly share code, notes, and snippets.

View willpearse's full-sized avatar

Will Pearse willpearse

  • Imperial College London
  • Silwood Park, UK
  • X @willpearse
View GitHub Profile
@willpearse
willpearse / ml_reml_thunderdome
Last active September 1, 2015 23:27
Test of ML vs. REML Lambda estimation
#Headers
require(geiger)
require(phytools)
require(nlme)
#Wrappers
get.lam <- function(x) attr(x$apVar, "Pars")[1]
get.vars <- function(n, lam){
tree <- rcoal(n=n)
x <- fastBM(geiger::rescale(tree, 'lambda', lambda = lam),sig2=0.5) # Brownian motion
@willpearse
willpearse / nhl_minor_penalty_scrape
Last active August 29, 2015 14:20
Scraping player minor penalties from NHL
#Headers
require 'open-uri'
require 'nokogiri'
require 'set'
#Get all the penalty stats
results = []
(2011..2014).to_a.each do |year|
(0..30).to_a.map{|x| x * 40 + 1}.each do |player_count|
page = Nokogiri::HTML(open("http://espn.go.com/nhl/statistics/player/_/stat/minor-penalties/sort/minorPenalties/year/#{year}/seasontype/2/count/#{player_count}"))