This file contains 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
# coding: utf-8 | |
# import scipy.io as io | |
from scipy import linspace, io | |
from pylab import * | |
from cmath import phase | |
from math import * | |
# Load the .mat files | |
testData = io.loadmat('BelkinTestData_1.mat') | |
taggingData = io.loadmat('TaggingInfo_1.mat') |
This file contains 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
''' | |
Convert Yelp Academic Dataset from JSON to CSV | |
Requires Pandas (https://pypi.python.org/pypi/pandas) | |
By Paul Butler, No Rights Reserved | |
''' | |
import json | |
import pandas as pd |
This file contains 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
function [convf,k,results,xn] = mygaussseidel(A,b,x,niter,tol) | |
[nrow,~] = size(A); | |
convf = 0; | |
results(1,:) = x'; | |
xn = x; | |
for k = 1:niter | |
for i = 1:nrow |
This file contains 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
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 4K randomly from SSD 150,000 ns 0.15 ms | |
Read 1 MB sequentially from memory 250,000 ns 0.25 ms | |
Round trip within same datacenter 500,000 ns 0.5 ms |
This file contains 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
function [ L,A,B,C,D ] = mydivdiff( x, f ) | |
% INPUTS: x - Nx1 vector of x values at which data for the function is specified | |
% f - Nx1 vector of corresponding function values | |
% OUTPUTS: A - (N-1)x(N-1) table of divided differences | |
n = size(x,1); | |
L = zeros(n-1); | |
L(:,1) = (f(2:n)-f(1:n-1))./(x(2:n)-x(1:n-1)); |
This file contains 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
function results = mymultinewtfunction(x, func, niter, tol) | |
for i = 1:niter | |
n = max(size(x)); | |
%f = [(log(x(1)) - x(2)) , ((x(1)^2+2*x(1)-24)/25 - x(2))]; | |
%J = [1/x(1), -1 ; 2*x(1)/25+2/25 , -1]; | |
f = func(x); | |
J = zeros(n); | |
This file contains 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
./community --outfile=graph-cmap.bin --textoutfile=graph-cmap.txt --outgraph=comm-graph-el.bin --min-degree=2 --max-degree=72 --max-num-comm=10 --max-comm-size=30 --scoring=mb --matching=greedy --nsteps=10 output-el.bin | |
./community --textoutfile=graph-cmap.txt --outgraph=comm-graph-el.bin --min-degree=1 --max-degree=72 --max-num-comm=6 --max-comm-size=1000 --scoring=mb --matching=greedy --nsteps=50 output-el.bin |
This file contains 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
%Calls comptrap, doubles n each time | |
n=1; | |
old=0; | |
a=0; | |
b=1; | |
i=0; | |
A=zeros(20,1); | |
B=zeros(20,1); | |
global r |
This file contains 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
# -*- coding: utf-8 -*- | |
#!/usr/bin/env python | |
import sys | |
class Polyomino(object): | |
def __init__(self, iterable): | |
self.squares = tuple(sorted(iterable)) | |
def __repr__(self): |
This file contains 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 numpy import * | |
from scipy.stats import beta | |
class BetaBandit(object): | |
def __init__(self, num_options=2, prior=(1.0,1.0)): | |
self.trials = zeros(shape=(num_options,), dtype=int) | |
self.successes = zeros(shape=(num_options,), dtype=int) | |
self.num_options = num_options | |
self.prior = prior |