This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Corey Chivers, 2012 ## | |
sim_bayes<-function(p=0.5,N=100,y_lim=20,a_a=2,a_b=10,b_a=8,b_b=3) | |
{ | |
## Simulate outcomes in advance | |
outcomes<-sample(1:0,N,prob=c(p,1-p),replace=TRUE) | |
success<-cumsum(outcomes) | |
for(frame in 1:N) | |
{ | |
png(paste("plots/",1000+frame,".png",sep="")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################## Plot training skies ################### | |
## | |
## [email protected] | |
## | |
########################################################## | |
## calculate a vector given | |
## x,y,e1,e2 | |
gal_line<-function(g,scale=100) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################### | |
## Intro to Simulation - R/Stats Intro Series | |
## Designed by: Corey Chivers, 2013 | |
## Department of Biology, McGill University | |
######################################################### | |
##@ 0.1 @## | |
rm(list=ls()) # Housekeeping | |
#setwd('<my working directory>') # set working dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Simulate Grime Dice ## | |
red<-c(4,4,4,4,4,9) | |
blue<-c(2,2,2,7,7,7) | |
olive<-c(0,5,5,5,5,5) | |
yellow<-c(3,3,3,3,8,8) | |
magenta<-c(1,1,6,6,6,6) | |
## Play n match-ups between d1 and d2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################### | |
## | |
## Functions for calculating AUC and plotting ROC | |
## Corey Chivers, 2013 | |
## [email protected] | |
## | |
################################################### | |
## Descrete integration for AUC calc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Functions for simulating Conway's Game of Life | |
## Modified from http://www.petrkeil.com/?p=236 | |
neighbour_count <- function(X) | |
{ | |
side <- nrow(X) | |
# make the shifted copies of the original array | |
allW = cbind( rep(0,side) , X[,-side] ) | |
allNW = rbind(rep(0,side),cbind(rep(0,side-1),X[-side,-side])) | |
allN = rbind(rep(0,side),X[-side,]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Parse BMC OA articles from XML to utf-8 text of the title, abstract, and body. | |
""" | |
import libxml2 | |
from os import listdir | |
from time import gmtime, strftime | |
input_dir = './BMC_FTP/content/articles/' | |
files = listdir(input_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Warren Buffet's 1B Basketball Challenge ## | |
expected_value <- function(p,ngames=63,prize=1000000000){ | |
p^ngames * prize | |
} | |
## What is the expected value of an entry | |
## given a particular level of prediction accuracy | |
expected_value(p=0.80) | |
expected_value(p=0.85) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_correlogram(df,figsize=(20,20)): | |
''' Creat an n x n matrix of scatter plots for every | |
combination of numeric columns in a dataframe''' | |
cols = list(df.columns[df.dtypes=='float64']) | |
n = len(cols) | |
fig, ax = plt.subplots(n,n,figsize=figsize) | |
for i,y in enumerate(cols): | |
for j,x in enumerate(cols): | |
if i != n-1: |
OlderNewer