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 java.util.*; | |
import it.unimi.dsi.fastutil.ints.IntOpenHashSet; | |
public class Stupid { | |
public static void run() { | |
for(int N = 32; N<=1048576;N*=2) { | |
int[] x = new int[N]; | |
Random rand = new Random(); |
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
package implicitfuck; | |
import metascala.Nats._; | |
import metascala.TLists._; | |
object ImplicitFuck { | |
type < = _0 // Left | |
type > = _1 // Right | |
type |# = _2 // while | |
type #| = _3 // end while | |
type + = _4 // inc |
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 am getting stuck in interpreting joint and conditional probabilities while trying to understand some | |
>>language modeling stuff. Given w (the words in a corpus of documents), and z (the topics), and T (the number | |
>>of topics), how would you interpret the following: (1) P(*w*|T), (2) P(*w*|*z*, T) and (3) P(*z*|*w*, T)? | |
>>Thanks! | |
First, bayes rule: | |
p(z|w,t) = p(w|z,t)p(z|t)/p(w|t) | |
"the posterior probability is proportional to the prior probability (p(z|T)) times conditional likelihood (p(w|z,T))" The other term makes it normalize. |
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 improve(image: Image, desc: String) = for { | |
page = generateImprovementPage(image,desc); | |
improvement <- runHits(page) | |
} yield improvement; | |
def vote(improvement: Improvement) = for { | |
page = generateVotingPage(improvement); | |
v <- runHits(page); | |
} yield v; |
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 producerToIterator[L](prod : =>L):Iterator[L] = new Iterator[L] { | |
private var current: Option[L] = None | |
def hasNext = current != None || { | |
current = prod match { | |
case null => None | |
case x => Some(x); | |
}; | |
current != 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
implicit class RichString(s: String) extends RandomAccessSeq[Char] { | |
def apply(x: Int) = s.charAt(x); | |
// whatever | |
var foo = 3; | |
def twiddle = { foo += 1; foo } | |
} | |
yields | |
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
implicit class RichString(s: String) extends RandomAccessSeq[Char] { | |
def apply(x: Int) = s.charAt(x); | |
// whatever | |
var foo = 3; | |
def twiddle = { foo += 1; foo } | |
} | |
yields |
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
A gnostic was seated before a grammarian. The grammarian | |
said, ‘A word must be one of three things: either it is a noun, a | |
verb, or a particle.’ The gnostic tore his robe and cried, “Alas! | |
Twenty years of my life and striving and seeking have gone to the | |
winds, for I laboured greatly in the hope that there was another | |
word outside of this. Now you have destroyed my hope.’ Though | |
the gnostic had already attained the word which was his purpose, | |
he spoke thus in order to arouse the grammarian. | |
-- Rumi, trans. A.J. Arberry |
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
private[hadoop] def runMapReduce[K1,V1,K2,V2,K3,V3](paths : Array[Path], | |
m: Mapper[K1,V1,K2,V2], | |
r: Reduce[K2,V2,K3,V3]) | |
(implicit mk2:Manifest[K2], mv2:Manifest[V2], | |
mk3:Manifest[K3], mv3:Manifest[V3]) = { | |
implicit val jobConf = new JobConf(conf, m.getFunClass); | |
val outputPath = genDir; | |
jobConf.setJobName("SMR-"+outputPath.getName); |
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
private[hadoop] def runMapReduce[K1,V1,K2,V2,K3,V3](paths : Array[Path], | |
m: Mapper[K1,V1,K2,V2], | |
r: Reduce[K2,V2,K3,V3]) | |
(implicit mk2:Manifest[K2], mv2:Manifest[V2], | |
mk3:Manifest[K3], mv3:Manifest[V3]) = { | |
implicit val jobConf = new JobConf(conf, m.getFunClass); | |
val outputPath = genDir; | |
jobConf.setJobName("SMR-"+outputPath.getName); |