-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5e531a2
Showing
8 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Compiled source # | ||
################### | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.o | ||
*.so | ||
|
||
# Packages # | ||
############ | ||
# it's better to unpack these files and commit the raw source | ||
# git has its own built in compression methods | ||
*.7z | ||
*.dmg | ||
*.gz | ||
*.iso | ||
*.jar | ||
*.rar | ||
*.tar | ||
*.zip | ||
|
||
# Logs and databases # | ||
###################### | ||
*.log | ||
*.sql | ||
*.sqlite | ||
|
||
# OS generated files # | ||
###################### | ||
.DS_Store* | ||
ehthumbs.db | ||
Icon? | ||
Thumbs.db | ||
|
||
# Node.js # | ||
########### | ||
lib-cov | ||
*.seed | ||
*.log | ||
*.csv | ||
*.dat | ||
*.out | ||
*.pid | ||
*.gz | ||
|
||
pids | ||
logs | ||
results | ||
|
||
node_modules | ||
npm-debug.log | ||
|
||
# Components # | ||
############## | ||
|
||
/build | ||
/components | ||
|
||
# ImageMagick # | ||
############### | ||
|
||
*.cache | ||
*.mpc | ||
|
||
# Other # | ||
######### | ||
test/*.2 | ||
test/*/*.2 | ||
test/*.mp4 | ||
test/images/originalSideways.jpg.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test.js |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_js: | ||
- "0.10" | ||
language: node_js |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
BIN = ./node_modules/.bin/ | ||
|
||
test: | ||
@${BIN}mocha --reporter spec | ||
|
||
.PHONY: test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "wilson-score", | ||
"description": "Because averages suck", | ||
"version": "0.0.1", | ||
"license": "MIT", | ||
"scripts": [ | ||
"index.js" | ||
], | ||
"main": "index.js", | ||
"repo": "jonathanong/wilson-score" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = function (up, total, z) { | ||
// http://amix.dk/blog/post/19588 | ||
// 95% = 1.644853 | ||
// 99% = 2.326348 | ||
z = z || 2.326348 | ||
if (total <= 0 || total < up) | ||
return 0 | ||
|
||
var phat = up/total, z2 = z*z; | ||
return (phat + z2/(2*total) - z*Math.sqrt((phat*(1 - phat) + z2/(4*total))/total))/(1 + z2/total) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "wilson-score", | ||
"description": "Because averages suck", | ||
"version": "0.0.1", | ||
"author": { | ||
"name": "Jonathan Ong", | ||
"email": "[email protected]", | ||
"url": "http://jongleberry.com", | ||
"twitter": "https://twitter.com/jongleberry" | ||
}, | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jonathanong/wilson-score.git" | ||
}, | ||
"bugs": { | ||
"mail": "[email protected]", | ||
"url": "https://github.com/jonathanong/wilson-score/issues" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
}, | ||
"scripts": { | ||
"test": "make test;" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var assert = require('assert') | ||
|
||
var wilson = require('./') | ||
|
||
describe('Wilson Score', function () { | ||
it('should be lower than the average', function () { | ||
assert.ok(wilson(3, 5) < 3 / 5) | ||
}) | ||
|
||
it('should be 0 if there are no ups', function () { | ||
assert.equal(wilson(0, 100), 0) | ||
}) | ||
}) |