This file contains hidden or 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
# ipak function: install and load multiple R packages. | |
# check to see if packages are installed. Install them if they are not, then load them into the R session. | |
ipak <- function(pkg){ | |
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])] | |
if (length(new.pkg)) | |
install.packages(new.pkg, dependencies = TRUE) | |
sapply(pkg, require, character.only = TRUE) | |
} |
This file contains hidden or 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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<head> | |
<style> | |
.enter { | |
fill: green; | |
} | |
.update { |
This file contains hidden or 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 | |
FILE="${1}" | |
if [[ $# != 1 ]]; then | |
echo "Usage: ./render_post.sh <file>" | |
exit | |
fi | |
if [[ ! -f "${FILE}" ]]; then |
This file contains hidden or 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/env Rscript | |
input <- commandArgs(trailingOnly = TRUE) | |
KnitPost <- function(input, base.url = "/") { | |
require(knitr) | |
opts_knit$set(base.url = base.url) | |
fig.path <- paste0("../figs/", sub(".Rmd$", "", basename(input)), "/") | |
opts_chunk$set(fig.path = fig.path) | |
opts_chunk$set(fig.cap = "center") | |
render_jekyll() |
This file contains hidden or 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
import numpy as np | |
#A simple observation series | |
obs = np.array([0, 0, 1, 0, 0]) | |
#initial state occupation probabilities | |
#(flat prior over state occupancies when t = 0) | |
initProbs = np.ones(4)/4 | |
#These are the time-constant transition *rates* (with zeros |
This file contains hidden or 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
#Forward-backward algorithm implementation in Theano, | |
#with example taken from Wikipedia: | |
#http://en.wikipedia.org/wiki/Forward%E2%80%93backward_algorithm | |
import theano | |
import theano.tensor as T | |
import numpy as np | |
#Set up vectors, etc to represent | |
#observations, indexes into the observation |
This file contains hidden or 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
import random | |
import scipy | |
import pylab as pl | |
pl.figure() | |
for i in range(30): | |
S = 99999 | |
I = 1 | |
R = 0 |
This file contains hidden or 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
#a simple network-based SIR model written in Python | |
#Jon Zelner | |
#University of Michigan | |
#October 20, 2009 | |
#import this file (networkSIRWithClasses) to use the model components | |
#or run as 'python networkSIRWithClasses.py' to do sample runs | |
import igraph | |
import random |
This file contains hidden or 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
#a simple object-based SIR model written in Python | |
#Jon Zelner | |
#University of Michigan | |
#October 20, 2009 | |
#import 'sirWithClasses' to use the components of this model as you wish | |
#or just run this script as 'python sirWithClasses.py' to do a sample model run | |
import random | |
import heapq |
This file contains hidden or 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
#A simple SIR model written in Python | |
#Jon Zelner | |
#University of Michigan | |
#October 8, 2009 | |
#Ok, so first we're going to import our random number and plotting libraries | |
# this is Python's standard random number library. | |
#For heavy-duty applications you'll want to use something else | |
#(like Scipy) but for this example, this will be more than adequate. |
NewerOlder