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
## Development utilities for XX | |
## | |
## Usage: | |
## make <target> [<arg>=<value> ...] | |
## | |
## Targets: | |
## help: Show this help message. | |
## env: Create or update conda environment "XX" | |
ENV?=XX |
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
import os | |
import pandas as pd | |
def read_auto(datapath): | |
_, ext = os.path.splitext(datapath) | |
if ext == ".csv": | |
return pd.read_csv(datapath) | |
elif ext == ".tsv": | |
return pd.read_csv(datapath, sep="\t") |
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/bash | |
repos=$(gh repo list -L=9999 | awk '{print $1}') | |
for r in $repos; do gh repo clone $r; 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
--- | |
title: "Stan templates" | |
output: html_notebook | |
--- | |
**Things to keep in mind:** | |
- Stan uses the *standard deviation* to parameterize the normal distribution. Use `normal(mu, sigma)` instead of `normal(mu, sigma^2)`. | |
- Leave a blank line at the end of the chunk defining Stan code. |
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
library(assert) | |
source("multinorm.R") | |
rnormalgamma <- (function(k, b, Sigma, nu, kappa) { | |
# Sample from a Normal-Gamma distribution Attaches both `rnormalgamma` and | |
# `rnormalgamma.fast` to the current environment. | |
# | |
# Usage: | |
# rnormalgamma(b, Sigma, nu, kappa) | |
# rnormalgamma.fast(b, Sigma, nu, kappa) |
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
# | |
# Work in progress. | |
# | |
cmap.seaborn <- function(n) { | |
colors.seaborn <- | |
c(rgb(0.12156862745098039, 0.4666666666666667, 0.7058823529411765), | |
rgb(1.0, 0.4980392156862745, 0.054901960784313725), | |
rgb(0.17254901960784313, 0.6274509803921569, 0.17254901960784313), | |
rgb(0.8392156862745098, 0.15294117647058825, 0.1568627450980392), |
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
library(assert) | |
rmultinorm.fast <- function(k, mu, sigma) { | |
p = length(mu) | |
t(chol(sigma)) %*% matrix(rnorm(p*k, 0, 1), nrow=p) + mu | |
} | |
#' Sample from a multivariate normal distribution. Attaches both `rmultinorm` | |
#' and `rmultinorm.fast` to the current environment. | |
#' |
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
assert <- function(..., msg=NULL) { | |
# Assert that each of the provided expression is true. Otherwise returns a | |
# description of each failed assertion. | |
# | |
# Args: | |
# ...: List of logical assertions | |
# msg: Optional parameter printed when one of the assertions fails. | |
# | |
# Returns: | |
# Nothing if all assertions pass. Otherwise throws an error describing which |