Skip to content

Instantly share code, notes, and snippets.

perimosocordiae / .block
Last active Dec 16, 2016
Sonified Line Chart
View .block
license: gpl-3.0
perimosocordiae /
Created Sep 25, 2015
Asymmetric Least Squares
import numpy as np
from scipy.linalg import solveh_banded
def als_baseline(intensities, asymmetry_param=0.05, smoothness_param=1e6,
max_iters=10, conv_thresh=1e-5, verbose=False):
'''Computes the asymmetric least squares baseline.
smoothness_param: Relative importance of smoothness of the predicted response.
import numpy as np
from scipy.sparse.csgraph import minimum_spanning_tree
from sklearn.metrics import pairwise_distances
def perturbed_mst(X, num_perturbations=20, jitter=None):
'''Builds a graph as the union of several MSTs on perturbed data.
Reference:, page 8
jitter refers to the scale of the gaussian noise added for each perturbation.
When jitter is None, it defaults to the 5th percentile interpoint distance.'''
perimosocordiae /
Created May 21, 2012
User-friendly interface to scipy's curve_fit function
#!/usr/bin/env python
from scipy.optimize import curve_fit
import re
from math import *
from numpy import *
from sys import stdin
from optparse import OptionParser
op = OptionParser(usage='%prog [options] <function_of_x> [input_file]')
perimosocordiae /
Created Mar 23, 2010
PCA-based face recognition
#!/usr/bin/env python
from sys import argv, exit
from glob import glob
from matplotlib.pyplot import show, imshow, subplot, gray
from matplotlib.image import imread
from numpy import zeros,dot,sum,arange,savez,load,flipud,array
from scipy.linalg import eig
ATT = False
CLIP = False
#!/usr/bin/env python
import stereogram as s
import numpy as np
from sys import argv,exit
from os import system
from os.path import splitext
from PIL import Image,ImageSequence
# axis: 0 is up/down, 1 is left/right
#!/usr/bin/env python
from PIL import Image
import numpy as np
from sys import argv,exit
from random import randint
from time import time
from math import ceil
from weave import inline,converters
perimosocordiae / forth.rb
Created Feb 10, 2010
A pure Ruby interpreter for Forth
View forth.rb
#!/usr/bin/env ruby
# the stack
$stack = []
def pop() $stack.pop || ufe end
def push(f) $stack<<f end
# poor man's Exception class
def ufe() raise("Stack underflow") end
# lambda constructor helpers