Skip to content

Instantly share code, notes, and snippets.

View kylebgorman's full-sized avatar

Kyle Gorman kylebgorman

View GitHub Profile
@kylebgorman
kylebgorman / TIMIT+.py
Created February 18, 2012 02:08
TIMIT+: Make TIMIT bearable (see top for instructions)
#!/usr/bin/env python
#
# TIMIT+.py: make TIMIT bearable to use
# Kyle Gorman <kgorman@ling.upenn.edu
#
# To use this:
# 1. place in the same directory as a copy of TIMIT
# 2. install SoX and textgrid.py
# 3. run ./TIMIT+.py
#
@kylebgorman
kylebgorman / martini.c
Created June 10, 2012 23:08
Recursive martini class
// A cool way to draw a martini glass; this was on the final of CS 115 at U of I
#include <stdio.h>
void drawcup(int N, int offset) {
// base case
if (offset > N)
return;
@kylebgorman
kylebgorman / em2gaus.py
Created June 26, 2012 00:02
EM for a mixture of 2 univariate Gaussians
#!/usr/bin/env python
#
# Copyright (c) 2012 Kyle Gorman
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@kylebgorman
kylebgorman / Getopt.java
Created July 12, 2012 17:46
BSD-licensed Getopt for Java
/**
* Copyright (C) 2012 Kyle Gorman
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@kylebgorman
kylebgorman / .vimrc
Last active October 23, 2023 21:57
my .vimrc (pretty basic)
syn on
set hlsearch
set ruler
" tab stuff
set expandtab
set tabstop=4
" scrolling
set scrolloff=5
" backspace over everythign
set backspace=indent,eol,start
@kylebgorman
kylebgorman / autoloess.R
Last active November 28, 2022 16:06
autoloess.R: set the "span" (smoothing) hyperparameter for a LOESS curve so as to minimize AIC_c (includes a cute demonstration)
# autoloess.R: compute loess metaparameters automatically
# Kyle Gorman <gormanky@ohsu.edu>
aicc.loess <- function(fit) {
# compute AIC_C for a LOESS fit, from:
#
# Hurvich, C.M., Simonoff, J.S., and Tsai, C. L. 1998. Smoothing
# parameter selection in nonparametric regression using an improved
# Akaike Information Criterion. Journal of the Royal Statistical
# Society B 60: 271–293.
@kylebgorman
kylebgorman / lda-match.R
Created September 8, 2013 00:36
lda-match.R: perform group matching via backward selection using a heuristic based on Fisher's linear discriminant
#!/usr/bin/env Rscript
# lda-match.R: Perform group matching via backward selection using a heuristic based on Fisher's
# linear discriminant
# Kyle Gorman <gormanky@ohsu.edu>
require(MASS)
lda.match <- function(x, grouping, term.fnc=univariate.all) {
# Create a matched group via backward selection using a heuristic
# based on Fisher's linear discriminant. Observations are removed
@kylebgorman
kylebgorman / match-frag1.R
Created September 28, 2013 00:56
Define the search space for the matching procedure
# compute means
mu <- mean(covariate)
mu.group <- tapply(covariate, condition, mean)
# locate observations driving the correlation
correlate <- ((covariate < mu.group) == (mu.group < mu))
# compute order, filtering out non-correlates
ord <- order(covariate)
ord <- ord[correlate[ord]]
# split on condition and reverse for those above
search.space <- split(ord, condition[ord])
@kylebgorman
kylebgorman / dictpp.py
Created November 2, 2013 06:01
a Python dictionary with all the set operators
#!/usr/bin/env python -O
#
# Copyright (c) 2013 Kyle Gorman
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
@kylebgorman
kylebgorman / wagnerfischerpp.py
Last active March 3, 2023 17:27
Wagner-Fischer Levenshtein distance, now with a means to generate all possible optimal alignments.
# Copyright (c) 2013-2022 Kyle Gorman
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#