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 BinomialHypothesisTest { | |
def tTestBinomial(p1:Double, n1:Int, p2:Double, n2:Int): TtestRes = { | |
val k = (n1*p1 + n2*p2) / (n1 + n2).toDouble | |
val z = (p1 - p2) / math.sqrt( k*(1 - k) * (1 / n1.toDouble + 1 / n2.toDouble) ) | |
if(z > scoreForTwoTailed95CiPval) | |
RejectNull | |
else | |
FailToReject | |
} |
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
#include <cmath> | |
#include <iostream> | |
using std::cout; | |
using std::endl; | |
float quake3_hack(float number) { | |
float x2 = number * 0.5f; | |
float y = number; | |
long i = *(long*) & y; |
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
UNDERSTANDING HASH FUNCTIONS | |
by Geoff Pike | |
Version 0.2 --- early draft --- comments and questions welcome! | |
References appear in square brackets. | |
1 INTRODUCTION | |
Hashing has proven tremendously useful in constructing various fast | |
data structures and algorithms. It is typically possible to simplify |
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 functools import partial | |
from operator import concat | |
from os.path import isfile | |
from fold import foldl | |
def _list_files_from(part, prev): | |
current = "%s/%s" % (prev, part) | |
if isfile(current): |
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 rapture.io._ | |
// Let's parse some JSON | |
val src: Json = Json.parse(""" | |
{ | |
"foo": "Hello world", | |
"bar": { | |
"baz": 42 | |
} | |
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
case class Scored[T](item: T, value: Double) | |
trait Val[-A] { | |
def valueOf(a: A): Double | |
} | |
object Val { | |
def apply[T: Val]: Val[T] = | |
implicitly[Val[T]] | |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/bin/bash | |
# Bash function to download a file with wget, showing a progress bar and enables | |
# re-downloading if interrupted. Also can automatically determine filename from | |
# supplied URL or override from command line. | |
# First argument is URL. | |
# Second optional argument is filename. | |
download () { | |
local URL="$1" | |
local FI="$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
package mapreduce | |
/** | |
* This is an attempt to find a minimal set of type classes that describe the map-reduce programming model | |
* (the underlying model of Google map/reduce, Hadoop, Spark and others) | |
* The idea is to have: | |
* 1) lawful types that fully constrain correctness | |
* 2) a minimal set of laws (i.e. we can't remove any laws, | |
* 3) able to fully express existing map/reduce in terms of these types | |
* |