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
#!/bin/bash | |
# Convert all pdf to png | |
for f in *.pdf | |
do | |
convert "$f" "${f%.pdf}.png" | |
done |
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
[flickr-gallery mode="search" tags="adaptivedynamics" min_upload_date="2011-01-06 00:00:00" max_upload_date="2011-01-06 23:59:59"] | |
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
setOldClass("myS3Class") | |
setGeneric("foo", function(x, ...) standardGeneric("foo")) | |
foo = | |
function(x, ...) | |
UseMethod("foo") | |
foo.myS3Class = |
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
########################################################## | |
# King Markov, island dictator example | |
# this is a simple metropolis algorithm | |
num.visits <- 20000 | |
population <- 1:10 | |
current.island <- sample( 1:10 , size=1 ) | |
visits <- {} | |
par(mfrow=c(2,1)) | |
for ( i in 1:num.visits ) { | |
visits[i] <- current.island |
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
########################################################## | |
# show updating process iteratively | |
# just paste all of this code into R to execute it | |
# generate data | |
n <- 20 | |
y <- rnorm( n , mean=7 , sd=0.5 ) | |
# assign prior and compute posterior as we add each y value to observations | |
prior.mu <- 3 | |
k.sigma<-sd(y) |
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
# @file: abc.R | |
# @author: Carl Boettiger <cboettig@gmail.com> | |
# @date: 11 April, 2011 | |
# Description: A trivial example of Approximate Bayesian Computing | |
# We will simulate under a Gaussian process to determine | |
# The target data: | |
TrueMean <- 7 ## irrelevant note: "True" is rather a frequentist name for this | |
TrueSD <- 1 | |
Npts <- 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
## The observed data. | |
X <- rnorm(1000, 2, 5) | |
loglik <- function(mu, sigma, X){ | |
## The likelihood function | |
sum( dnorm(X, mean=mu, sd=sigma, log=TRUE) ) | |
} | |
## initial starting point | |
pars <- c(mu=5, sigma=15) |
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
# id <- "10255/dryad.23" | |
download_data <- function(id, curl=getCurlHandle() ){ | |
# Returns the url to data file | |
mets_metadata <- sprintf("%s/%s/%s", "http://datadryad.org/metadata/handle/", id, "/mets.xml") | |
tt <- getURLContent(mets_metadata, curl=curl) | |
page <- xmlParse(tt) | |
out <- xpathApply(page, "//mets:FLocat", | |
function(x){ | |
link <- xmlAttrs(x, "xlink:href") |
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
beta <- function(i, Delta_T=1){ | |
1/(1+Delta_T*(i-1)) | |
} | |
step_fn <- function(pars, stepsizes = .02){ | |
# Sequential random updating | |
j <- sample(1:length(pars), 1) | |
pars[j] <- rnorm(1, pars[j], stepsizes) | |
pars | |
} |