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 scipy.optimize import curve_fit | |
from collections import Counter, defaultdict | |
import numpy as np | |
import time | |
def f(xss, a, b, c, d, e, f): | |
""" | |
Polynomial function up to order 5 | |
""" | |
ret = [] |
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
I’ve worked in an economy that rewards someone who saves the lives of others on a battlefield with a | |
medal, rewards a great teacher with thank-you notes from parents, but rewards those who can detect | |
the mispricing of securities with sums reaching into the billions. In short, fate’s distribution of long | |
straws is wildly capricious. | |
From Warren Buffett's Giving Pledge | |
http://givingpledge.org/pdf/letters/Buffett_Letter.pdf |
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 record_poop(): | |
data = { | |
"Timestamp": time.strftime("%Y-%m-%d %H:%M"), | |
"Measurement": 'Poopy Diaper' | |
} | |
requests.post(MAGIC_FORM_URL, data) |
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
p (char *) [data bytes] |
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
<body> | |
<table width="100%"> | |
<tr> | |
<td colspan=3> | |
</td> | |
</tr> | |
<tr valign="top"> | |
<td width="15%"> <div ex:role="facet" ex:expression=".venue" ex:facetLabel="Venue"></div> |
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 initializeToCrfPotentials = { | |
for (tweetIdx <- 0 until _Y.size) { | |
for (tokenIdx <- 0 until _Y(tweetIdx).size) { | |
for (labelIdx <- 0 until _Y(tweetIdx)(tokenIdx).size) { | |
// Note: the +1 in token index is because of the <S> token at the beginning | |
// of the CRF potentials. | |
logger.info(tweetIdx + " " + tokenIdx + " " + labelIdx) | |
_Y(tweetIdx)(tokenIdx)(labelIdx) = _crfPotentials(tweetIdx)(tokenIdx + 1)(labelIdx) | |
} | |
} |
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 initializeToCrfPosteriors = { | |
_Y = emptyY // Initialize to all 0s | |
require (_Y.size == _crfPotentials.size) // Santiy check: both are over tweets | |
for (tweet <- 0 until _crfPotentials.size) { | |
_forwardBackward.setInput(_crfPotentials(tweet)) | |
val nodeMarginals = _forwardBackward.getNodeMarginals() | |
val nonBorderMarginals = nodeMarginals.slice(1, nodeMarginals.size - 1) |
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
/** | |
* log q(Z_i = k) less than or equal to | |
* log P(Z_i=k) (the prior) | |
* + log E_ { q(y_i),q(T_k) } Theta^T_REW f_REW(x_i,y_i,T_k) | |
* - log E_ { q(T_k) } Z_ { x_i } (Theta, T_k) | |
*/ | |
def update(td: TaggingDistribution, rd: RecordDistribution) = { | |
// Initialize to all -Infinity | |
_Z = logEmptyZ() |
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 update(td: TaggingDistribution, ad: AlignmentDistribution) = { | |
/* | |
* Setup: Create an empty set of records | |
*/ | |
var TPrime = List[Record]() | |
for (i <- 0 until _T.size) { | |
val r = new Record(i, _schema) | |
r.setThetaRewrite(_T(i).thetaRewrite) | |
TPrime = TPrime :+ r | |
} |
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 ListCase { | |
def matcher(l:List[Int]) { | |
l match { | |
case List(1,3,5,7) => println("Primes") | |
case List(_,_,_,3,_) => println("3 on 3") | |
case 1::rest => println("List starting with 1") | |
case List(_*) => println("Other list") | |
} | |
} | |
} |
OlderNewer