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 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 |
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 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 |
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
# Data from: http://www.ny1.com/content/top_stories/156599/now-available--2007-2010-nyc-teacher-performance-data#doereports | |
from pylab import * | |
from pandas import * | |
import re | |
def get_data(filename): | |
d = read_csv(filename, delimiter="\t") | |
d['teacher'] = d['teacher_name_first_1'] + " " + d['teacher_name_last_1'] | |
return d |
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 numpy import * | |
from pylab import * | |
x = rand(N) | |
y = x + random.normal(0, 0.4, size=(N,)) | |
subplot(211) | |
axis((0,1,0,1)) | |
scatter(x,y) | |
subplot(212) |
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
if ! ifconfig eth0 && ! -f /var/log/rewriting-net-rules; | |
then | |
echo "Mac address for eth0 is incorrect." | |
/bin/rm -rf /etc/udev/rules.d/70-persistent-net.rules | |
touch /var/log/rewriting-net-rules | |
echo "Rebooting now." | |
/sbin/reboot | |
else | |
/bin/rm /var/log/rewriting-net-rules | |
fi |
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 pylab import * | |
E = 1.5 # exercise level | |
height = 6*12 #Height in inches | |
a = E * (66 + 12.7*height) / 3500.0 | |
b = E * 6.23 / 3500 | |
g = E * 6.775 / (365*3500.0) | |
age_range = (28, 40) | |
t = arange(age_range[0]*365,age_range[1]*365) |
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
function FiniteStateMachine(states, transitions, initialState) { | |
var state = initialState; | |
this.getState = function() { | |
return state; | |
}; | |
this.transition = function(newState) { | |
if (_.detect(transitions, function(transition) { return (transition[0] == state) && (transition[1] == newState); })) { | |
if (('onExit' in states[state]) && (typeof states[state].onExit == '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
#!/bin/sh | |
if test -s /var/run/hadoop/elephantdb.pid; | |
then | |
OLDPID=`cat /var/run/hadoop/elephantdb.pid` | |
echo "Killing old elephant process, pid=$OLDPID" | |
kill $OLDPID | |
rm /var/run/hadoop/elephantdb.pid | |
fi; | |
nohup java elephantdb.main /elephant/global-conf.clj /usr/local/hadoop/conf/elephantdb-local-conf.clj "`date`" > /var/log/hadoop/elephantdb.log & |
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 pylab import * | |
from numpy import * | |
import matplotlib.cbook as cbook | |
from datetime import datetime | |
from scipy.interpolate import interp1d | |
def read_file(filename): | |
dates = [] | |
values = [] | |
for l in open(filename).readlines(): |
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
package stylewok.utils.writable; | |
import org.apache.hadoop.io.*; | |
import java.util.*; | |
import java.io.*; | |
public class UUIDToDoubleMapWritable extends HashMap<UUIDWritable,Double> implements Writable { | |
public UUIDToDoubleMapWritable() { } |