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 | |
import tensorflow as tf | |
sess = tf.Session() | |
TYPE=np.float64 | |
N = 1000000 | |
data = np.random.normal(0, 1, N).astype(TYPE) |
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 | |
import tensorflow as tf | |
from scipy.optimize import minimize | |
import matplotlib | |
matplotlib.use('PDF') | |
import matplotlib.pyplot as plt | |
# Generate dataset | |
data = np.random.normal(0, 1, 1000) |
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 scipy.stats | |
def clopper_pearson(k,n,alpha=0.32): | |
""" | |
http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval | |
alpha confidence intervals for a binomial distribution of k expected successes on n trials | |
Clopper Pearson intervals are a conservative estimate. | |
""" | |
lo = scipy.stats.beta.ppf(alpha/2, k, n-k+1) | |
hi = scipy.stats.beta.ppf(1 - alpha/2, k+1, n-k) | |
return lo, hi |
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 requests | |
data = requests.get('http://api.wunderground.com/api/INSERT_KEY_HERE/geolookup/conditions/q/Switzerland/Zurich.json').json() | |
location = data['location']['city'] | |
temp_c = data['current_observation']['temp_c'] | |
print "Current temperature in %s is: %s C" % (location, temp_c) |
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
"""Genetic Algorithmn Implementation | |
see: | |
http://www.obitko.com/tutorials/genetic-algorithms/ga-basic-description.php | |
""" | |
import random | |
class GeneticAlgorithm(object): | |
def __init__(self, genetics): | |
self.genetics = genetics | |
pass |
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
""" | |
Helper module for displaying ROOT canvases in ipython notebooks | |
Usage example: | |
# Save this file as rootnotes.py to your working directory. | |
import rootnotes | |
c1 = rootnotes.default_canvas() | |
fun1 = TF1( 'fun1', 'abs(sin(x)/x)', 0, 10) | |
c1.SetGridx() |