Skip to content

Instantly share code, notes, and snippets.

@cboettig
Created July 1, 2011 17:22
Show Gist options
  • Save cboettig/1059002 to your computer and use it in GitHub Desktop.
Save cboettig/1059002 to your computer and use it in GitHub Desktop.
Amazon cloud via segue
#segue_test.R
on.exit(stopCluster(myCluster))
library(segue)
setCredentials(getOption("amazon_key"), getOption("amazon_secret"))
# Jeffery Breen's example, adapted with "custom function" works fine
my_fun <- mean # a custom definition
myList <- NULL
set.seed(1)
for(i in 1:10){
a <- c(rnorm(999), NA)
myList[[i]] <- a
}
outputLocal <- lapply(myList, mean, na.rm=T)
myCluster <- createCluster(numInstances=2)
out <- emrlapply(myCluster, myList, my_fun, na.rm=T)
## fails on a CRAN library
require(sde)
# locally this works
x <- lapply(1:2, function(i) sde.sim(model="CIR", theta=c(6,2,1)) )
# map reduce version fails
x <- emrlapply(1:2, function(i) sde.sim(model="CIR", theta=c(6,2,1)) )
## fails to run on installed library
require(warningsignals)
pars <- c(Ro=5.0, m= -.04999, theta=500, sigma=5)
const_pars <- c(Ro=5.0, theta=500, sigma=5)
## Some initial data: Simulate some sample data under slow linear change
deteriorating <- lapply(1:2, function(i) simulateGauss(timedep_LSN, pars, N=100, T=100, Xo=500))
deteriorating <- emrlapply(1:2, function(i) simulateGauss(timedep_LSN, pars, N=100, T=100, Xo=500))
stopCluster(myCluster)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment