This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
def ttest(x1, x2): | |
"Student's t-test for unpaired, equal variance, equal size samples." | |
if len(x1) != len(x2): | |
raise ValueError('unequal sample sizes') | |
mx1 = sum(x1) / len(x1) | |
mx2 = sum(x2) / len(x2) | |
s2x1 = sum((xi - mx1)**2 for xi in x1) / (len(x1) - 1) | |
s2x2 = sum((xi - mx2)**2 for xi in x2) / (len(x2) - 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# | |
# K-means clustering using Lloyd's algorithm in pure Python. | |
# Written by Lars Buitinck. This code is in the public domain. | |
# | |
# The main program runs the clustering algorithm on a bunch of text documents | |
# specified as command-line arguments. These documents are first converted to | |
# sparse vectors, represented as lists of (index, value) pairs. | |
from collections import defaultdict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PI = Math.PI; | |
//Faster replacement for Math object methods. | |
Math.round(PI) === PI + (PI < 0 ? -0.5 : +0.5) >> 0; | |
Math.ceil(PI) === PI + (PI < 0 ? -1 : 0) >> 0; | |
Math.floor(PI) === PI + (PI < 0 ? -1 : 0) >> 0; | |
//Conditional operator is faster than Math object methods. | |
Math.max(a, b) === (a > b) ? a : b; | |
Math.min(a, b) === (a < b) ? a : b; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin linear-gradient($angle, $color-stops...) { | |
$_angle-with-vendor-prefix: ""; | |
$_angle: ""; | |
@if $angle == "to top" or $angle == "bottom" { | |
$_angle-with-vendor-prefix: bottom; | |
$_angle: to top; | |
} @else if $angle == "to right" or $angle == "left" { | |
$_angle-with-vendor-prefix: left; | |
$_angle: to right; | |
} @else if $angle == "to bottom" or $angle == "top" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import cv2.cv as cv | |
def detect(img, cascade_fn='haarcascades/haarcascade_frontalface_alt.xml', | |
scaleFactor=1.3, minNeighbors=4, minSize=(20, 20), | |
flags=cv.CV_HAAR_SCALE_IMAGE): | |
cascade = cv2.CascadeClassifier(cascade_fn) | |
rects = cascade.detectMultiScale(img, scaleFactor=scaleFactor, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<title>Bus stops on UVic Bus Lines, Victoria, BC</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/d3/2.8.1/d3.v2.min.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/simplegeo/polymaps/v2.5.0/polymaps.min.js"></script> | |
<script type="text/javascript" src="jquery.qtip.min.js" ></script> | |
<link rel="stylesheet" type="text/css" href="jquery.qtip.min.css"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FFT = (function() { | |
"use strict"; | |
var FFT = function() { | |
initialize.apply(this, arguments); | |
}, $this = FFT.prototype; | |
var FFT_PARAMS = { | |
get: function(n) { | |
return FFT_PARAMS[n] || (function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js | |
*/ | |
var http = require('http'), | |
fs = require('fs'), | |
util = require('util'); | |
http.createServer(function (req, res) { | |
var path = 'video.mp4'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Author: Jeremy M. Stober | |
Program: TILES.PY | |
Date: Monday, March 31 2008 | |
Description: A simple CMAC implementation. | |
""" | |
import os, sys, getopt, pdb | |
from numpy import * |