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.pyplot as plt | |
import numpy as np | |
x = np.random.exponential(size=5000) | |
y = [ pow(x_,0.2654) for x_ in x] | |
plt.hist(y,bins=51) | |
plt.show() |
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
def running_on_local(): | |
return not running_on_domino() | |
def running_on_domino(): | |
return ( domino_run_id() is not None ) | |
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 pandas as pd | |
class ChainedAssignent: | |
""" Context manager to temporarily set pandas chained assignment warning. Usage: | |
with ChainedAssignment(): | |
blah | |
with ChainedAssignment('error'): |
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 subprocess | |
from lib.common.dominoUtil import running_on_local | |
from lib.config import PROJECT_PATH | |
import time | |
import psutil | |
import os | |
import numpy as np | |
def _recommended_threads(): | |
return psutil.cpu_count()-2 |
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 json | |
import urllib2 | |
import time | |
import pandas as pd | |
def fen_examples( max_users = 3, max_games_per_user=10, sleep_time = 15 ): | |
""" Grab some real game positions from the middle of actual games, and the result """ | |
users = users_in_team( team='coders' ) | |
records = list() | |
for user in users[ :max_users ]: |
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
#!/usr/bin/env bash | |
# Call stockfish engine on mac and return only the evaluation score | |
# Usage stockfish.sh 'r1b2rk1/4qppp/2pp4/pp6/3Bn3/PB3Q1P/1PP2PP1/3R1RK1' 5 mac 12 1024 | |
# Usage stockfish.sh 'r1b2rk1/4qppp/2pp4/pp6/3Bn3/PB3Q1P/1PP2PP1/3R1RK1' 5 mac 12 1024 | |
# Assumes the stockfish binary is called 'stockfish_'+binary | |
fen=$1 | |
seconds=${2:-3} | |
binary=${3:-mac} | |
threads=${4:-12} |
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
lambert_facts = ['Lambert was born the son of a tailor, and was expected by his father to continue in that profession.', | |
'Lamberts early fight for his education is a remarkable story---he had to sell drawings and writings to his classmates to buy candles for night study,', | |
'Lambert produced fundamental discoveries in cartography, despite being self-educated.', 'Lambert influenced hygrometry, pyrometry, pure mathematics and statistics.', | |
'Lambert was more famous as a philosopher than as a mathematician.', 'The Lambert projection is still in use in cartography.', | |
'Lambert was the first person to prove that pi is irrational.', 'Proofs that it is impossible to square the circle leaned on insights from Lambert.', | |
'Lambert found a series solution to the trinomial equation, by hand calculation.', 'Lamberts technique for solving general series reversion techniques was a forerunner to the Langrange Inversion Theorem.', | |
'Lambert discovered an |
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 flask import Flask, request, url_for | |
from scipy.optimize import bisect | |
import math | |
import numpy as np | |
app = Flask(__name__) | |
app.secret_key = 'Whatever' | |
@app.route('/') | |
def index(): |
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 pymc import Model, MCMC, deterministic, stochastic, Normal, Bernoulli, Beta, distributions | |
import numpy as np | |
def twinModelVars( p_identical = 0.5, p_down = 0.01, measurement = 2.5, measurementPrecision = 2.0 ): | |
""" Stylized model for twin Down Syndrome likelihood after a blood sample is taken from mother | |
containing a mixture of indicators from each foetus | |
:param p_identical: (Prior) probability of identical twins versus fraternal (0.1 for population) | |
:param p_down: (Prior) probability of Down Syndrome | |
:param measurement: Measured marker value |
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 pymc import Model, MCMC, deterministic, stochastic, Normal, Bernoulli, Beta, distributions | |
import numpy as np | |
def twinModelVars( p_identical = 0.5, p_down = 0.01, measurement = 2.5, measurementPrecision = 2.0 ): | |
""" Stylized model for twin Down Syndrome likelihood after a blood sample is taken from mother | |
containing a mixture of indicators from each foetus | |
:param p_identical: (Prior) probability of identical twins versus fraternal (0.1 for population) | |
:param p_down: (Prior) probability of Down Syndrome | |
:param measurement: Measured marker value |
NewerOlder