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
object Compositional { | |
type FunctionOfList[T1] = List[T1] => Option[Double] | |
def convertFunctionOfListToFunctionInf[T1](f: FunctionOfList[T1], support: Set[Integer]): (Stream[T1] => Option[Double]) = { | |
(xs: Stream[T1]) => | |
{ | |
val variablesThatMatter = support.toList.map(i => xs(i)) | |
val fx = f(variablesThatMatter) | |
fx |
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
ISDA_PERMITTED_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
ISDA_PRIME = 59575553 | |
def leiHash( lei, permittedChars = ISDA_PERMITTED_CHARS ): | |
""" Shorten 20 character alpha-numeric Legal Entity Identifier into 10 character alpha-numeric "short LEI" that | |
can be used as a Unique Trade Identifier (UTI) prefix. The algorithm is simply the modulo operation lifted from | |
integers to the space of alpha-numeric case-insensitive strings. | |
Argument | |
-------- |
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 math | |
import func | |
# These coincide with the choices hardwired into the spreadsheet provided to ISDA, so don't change them | |
ISDA_PERMITTED_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' # Don't change! | |
ISDA_PRIME = 59575553 | |
def _avoidReserved( s ): | |
""" Avoid clash with reserved namespace used by CFTC """ |
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 |
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
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
#!/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
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
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 |
OlderNewer