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 matplotlib | |
import json | |
# 538.json is from https://gist.github.com/CamDavidsonPilon/5238b6499b14604367ac | |
s = json.load( open("538.json") ) | |
matplotlib.rcParams.update(s) | |
# plots now use FiveThirtyEight styles |
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
{ | |
"lines.linewidth": 2.0, | |
"examples.download": true, | |
"patch.linewidth": 0.5, | |
"legend.fancybox": true, | |
"axes.color_cycle": [ | |
"#30a2da", | |
"#fc4f30", | |
"#e5ae38", | |
"#6d904f", |
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
def exponential_survival_data(n, cr=0.05, scale=1.): | |
t = stats.expon.rvs(scale=scale, size=n) | |
if cr == 0.0: | |
return t, np.ones(n, dtype=bool) | |
def pF(h): | |
v = 1.0*h/scale | |
return v / (np.exp(v)-1) - cr |
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
# using %matploblib <backend> also imports the following helpers | |
from matplotlib import pylplot as plt | |
from IPython.core.pylabtools import figsize |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 random | |
p1 = 0.9 | |
p2 = 0.1 | |
N = 10000 | |
s = 0.0 | |
i = 0 | |
while i < N: |
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
%pylab | |
import scipy.stats as stats | |
print "Best to use custom matplotlibrc located in /styles directory of BMH project." | |
figure( figsize= ( 8, 11 ) ) | |
#means = np.random.uniform( -4, 4, size = 5 ) | |
means = np.array([ 3.90933614, -1.15148996, 1.70045292, -3.27613385, -0.71058847]) |
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 android | |
from time import sleep | |
from requests import post | |
droid = android.Android() | |
SERVER = "http://artech.herokuapp.com" | |
ID = 0 | |
""" |
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 numpy as np | |
from sklearn.linear_model import LinearRegression | |
#create some random data. | |
x1 = np.random.randn(250,1) | |
x2 = 0.001*np.random.randn(250,1) - x1 | |
x3 = np.random.randn(250,1) | |
# Y is a linear combination of the created data, with | |
# weights (10,10,0.01) |
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 re | |
import random | |
CURLY_RE = re.compile( "\{(.*?)\}" ) | |
def spam( filename ): | |
file = open(filename, "r") |