Skip to content

Instantly share code, notes, and snippets.

View garthj88's full-sized avatar

Garth Johnson garthj88

  • San Francisco, CA
View GitHub Profile
@mbjoseph
mbjoseph / vioplot2.R
Last active December 9, 2020 17:06
Slight change to the vioplot function from Daniel Adler that plots median lines instead of points, and gives the option to plot either side of a violin rather than always both.
vioplot2 <- function (x, ..., range = 1.5, h = NULL, ylim = NULL, names = NULL,
horizontal = FALSE, col = "magenta", border = "black", lty = 1,
lwd = 1, rectCol = "black", colMed = "white", pchMed = 19,
at, add = FALSE, wex = 1, drawRect = TRUE, side="both")
{
datas <- list(x, ...)
n <- length(datas)
if (missing(at))
at <- 1:n
upper <- vector(mode = "numeric", length = n)
@mblondel
mblondel / statistical_tests.py
Last active May 9, 2024 00:46
t-test and wilcoxon-test examples in Python
# Mathieu Blondel, February 2012
# License: BSD 3 clause
# Port to Python of examples in chapter 5 of
# "Introductory Statistics with R" by Peter Dalgaard
import numpy as np
from scipy.stats import ttest_1samp, wilcoxon, ttest_ind, mannwhitneyu
# daily intake of energy in kJ for 11 women
@zachmayer
zachmayer / 1. Functions.R
Created December 29, 2011 18:05
Forecasting S&P 500
#Function to cross-validate a time series.
cv.ts <- function(x, FUN, tsControl, xreg=NULL, ...) {
#Load required packages
stopifnot(is.ts(x))
stopifnot(is.data.frame(xreg) | is.matrix(xreg) | is.null(xreg))
stopifnot(require(forecast))
stopifnot(require(foreach))
stopifnot(require(plyr))