Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@imadmali
imadmali / color_stdout.py
Created March 10, 2021 07:37
Python colored stdout/print
# Colored stdout in Python (based off of blender build scripts)
# Reference: https://stackoverflow.com/questions/287871/how-to-print-colored-text-to-the-terminal
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
@imadmali
imadmali / welch_t_test.R
Last active December 8, 2018 03:54
ab-testing
# data
x1 <- rnorm(10, 1.1, 3)
x2 <- rnorm(50, 0.7, 3)
v_x1 <- var(x1)
v_x2 <- var(x2)
n_x1 <- length(x1)
n_x2 <- length(x2)
# welch's t-stat
num <- mean(x1) - mean(x2)
@imadmali
imadmali / simple_recursive_function.R
Created October 30, 2018 01:42
Recursive function example in R
#' Sum of Vector (Recursive Function)
#' A recursive function to find the total sum of all the elements of a vector.
#' Logic: Sum any two elements of the vector. Concatenate this sum to the
#' vector, excluding the elements used to compute the sum. Pass this new vector
#' back into the function (the length should be the original length of the
#' vector minus 1). Terminate the recursion when the length of the vector is 1
#' (i.e. the total sum).
#' @param n A vector of numbers.
#' @return The sum of the vector.