Skip to content

Instantly share code, notes, and snippets.

View mcarlisle's full-sized avatar

M Carlisle mcarlisle

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mcarlisle on github.
  • I am mcarlisle (https://keybase.io/mcarlisle) on keybase.
  • I have a public key ASB1Anz1qLZfRJpa9vAHI-CvQYQBMK1SalGNwzG1dWeuDgo

To claim this, I am signing this object:

@mcarlisle
mcarlisle / gist:118cc950d1987234f5b96da0759affe0
Created June 13, 2019 05:52
Boston Census, 1970: Boston Housing dataset, column B above 0.26
Tract,B,Location
3534,0.351,Cambridge
3535,0.32,Cambridge
3393,0.364,Medford
0105,0.267,Boston
0704,0.294,Boston
0707,0.654,Boston
0708,0.837,Boston
0709,0.78,Boston
0712,0.486,Boston
@mcarlisle
mcarlisle / rotate_clockwise_inplace.py
Created May 30, 2019 19:11
rotate the elements of a 2-dimensional list-of-lists "matrix" clockwise 90 degrees, in-place
def rotate_clockwise_inplace(matrix):
""" Input: a list of n lists of n objects each.
Output: the same shape, with entries rotated 90 deg.
"""
m = matrix
n = len(m)
halfway_x = n//2
halfway_y = (n+1)//2 if n % 2 else n//2
for i in range(0,halfway_x):
for j in range(0,halfway_y):
@mcarlisle
mcarlisle / rotate_clockwise_recursive.py
Created May 30, 2019 19:06
rotate the elements of a 2-dimensional list-of-lists "matrix" clockwise 90 degrees, recursively
def rotate_clockwise_recursive(matrix):
""" Input: a list of n lists of n objects each.
Output: the same shape, with entries rotated 90 deg. Done recursively.
"""
# Base case: n = 0 or 1: nothing to do!
m = matrix # for ease of typing
n = len(m)
if n in {0,1}:
return m
else:
@mcarlisle
mcarlisle / rotate_clockwise_numpy.py
Created May 30, 2019 19:01
rotate the elements of a 2-dimensional list-of-lists "matrix" clockwise 90 degrees, with numpy
def rotate_clockwise_numpy(matrix):
""" Input: a list of lists of shape (n,n).
Output: the same object, with entries rotated 90 deg.
"""
import numpy as np
m = np.matrix(matrix)
temp = np.matrix(matrix) # same shape! we're writing over all of it.
n = len(matrix)
@mcarlisle
mcarlisle / skew_kurtosis.ipynb
Created May 13, 2019 20:02
skewness and (excess) kurtosis example, Python scipy.stats
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mcarlisle
mcarlisle / latex_test.ipynb
Created April 30, 2019 02:41
LaTeX in Jupyter notebook markdown cell
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mcarlisle
mcarlisle / fun.py
Last active April 30, 2019 02:29
attempt to embed Python code in Medium post
def HowFunIsThis(n):
return "TH" + n*"I" + "IS much fun!"