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
import ghalton | |
from pylab import * | |
from scipy.stats import gamma | |
def qmc_gamma(alpha, N): | |
M = len(alpha) | |
sequencer = ghalton.Halton(2*M) | |
valid = ones(shape=(N,), dtype=bool) | |
hs = array(sequencer.get(N)).transpose() |
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
#Created graph used here: http://crazybear.posterous.com/structural-shift-in-the-economy | |
import numpy.numarray as na | |
from pylab import * | |
labels = ["Financial Activites", | |
"Construction", | |
"Information Services", | |
"Retail", |
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 pylab import * | |
from scipy.stats import uniform | |
gamma = 0.01/12.0 | |
t = arange(0,360) | |
def compute_payout(payout): | |
return (payout * exp( - gamma * t)).sum() | |
def generate_payout(): |
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 pylab import * | |
from scipy.stats import uniform | |
gamma = 0.01/12.0 | |
t = arange(0,360) | |
num_mortgages=50 | |
def compute_payout(payout): | |
return (payout * exp( - gamma * t)).sum() |
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 pylab import * | |
import random | |
from scipy.stats import beta, uniform | |
prior = beta(1,1) | |
class Bandit(object): | |
def __init__(self): | |
self.history = [(1.0,1.0), (1.0,1.0)] |
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
import matplotlib | |
matplotlib.use("WXAgg") | |
from pylab import * | |
from scipy.stats import beta, uniform, norm | |
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 |
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 pylab import * | |
from numpy.random import dirichlet, rand | |
def _unit_weight(dim): | |
return ones(dim) / float(dim) | |
def _feature_vec(dim, storage = None): | |
result = rand(dim) | |
result[where(result > 0.5)] = 1.0 | |
result[where(result <= 0.5)] = 0.0 |
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 pylab import * | |
from numpy.random import dirichlet, rand, binomial, uniform, normal | |
def _unit_weight(dim): | |
return ones(dim) / float(dim) | |
ONE_FRAC = 0.5 | |
SQRT_TWO_INV = 1.0 / sqrt(2.0) | |
def _feature_vec(dim, method="bernoulli"): | |
if method == "bernoulli": |
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 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 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 |