Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am jribnik on github.
  • I am jribnik (https://keybase.io/jribnik) on keybase.
  • I have a public key ASC_6pBE8vBSFFf0Xwc66rwKuoBO2QcUuZasJlhF-u4Q6Ao

To claim this, I am signing this object:

View 2015simulation.js
{
"waitedMS": NumberLong("0"),
"result": [
{
"_id": 1,
"DEN_avg_score": 19.734966125000213,
"DEN_avg_score_std": 10.506752595928164,
"DEN_win_pct": 0.33637,
"CAR_avg_score": 25.478733875000064,
"CAR_avg_score_std": 9.017951575045746,
View 2014simulation.js
{
"waitedMS": NumberLong("0"),
"result": [
{
"_id": 1,
"NE_avg_score": 25.848926249999767,
"NE_avg_score_std": 7.987140220020844,
"NE_win_pct": 0.45769,
"SEA_avg_score": 27.127344999999792,
"SEA_avg_score_std": 9.1468726553133,
View 2013simulation.js
{
"waitedMS": NumberLong("0"),
"result": [
{
"_id": 1,
"DEN_avg_score": 28.743076249999753,
"DEN_avg_score_std": 9.011384256852498,
"DEN_win_pct": 0.58883,
"SEA_avg_score": 25.868169249999788,
"SEA_avg_score_std": 9.032120640996355,
@jribnik
jribnik / final.js
Last active Feb 4, 2016
Aggregation stages for ensemble calculation
View final.js
proj0 = {"$project":
{
"i": 1,
"DEN_score": {"$sum": {"$cond": [{"$eq": ["$team", "DEN"]}, {"$multiply": [{"$subtract": [{"$divide": ["$yards", 80]}, "$turnovers"]}, 7]}, 0]}},
"CAR_score": {"$sum": {"$cond": [{"$eq": ["$team", "CAR"]}, {"$multiply": [{"$subtract": [{"$divide": ["$yards", 80]}, "$turnovers"]}, 7]}, 0]}}
}
}
group0 = {"$group":
{
"_id": "$i",
@jribnik
jribnik / 2015simulation0.js
Last active Feb 4, 2016
Example simulation documents
View 2015simulation0.js
> db.pbp_2015_simulations.find({"i": 0})
{
"_id": ObjectId("56a7e1bc87776355710ff107"),
"yards": 479,
"turnovers": 2,
"team": "DEN",
"i": 0
}
{
"_id": ObjectId("56a7e1bc87776355710ff108"),
@jribnik
jribnik / group.js
Last active Feb 4, 2016
$group stage of simulation pipeline
View group.js
group = {"$group":
{
"_id": "$team",
"yards": {"$sum": "$yards"},
"turnovers": {"$sum": "$turnovers"}
}
}
@jribnik
jribnik / project.js
Last active Feb 4, 2016
$project stage of simulation pipeline
View project.js
proj = {"$project":
{
"team": "$OffenseTeam",
"yards": "$Yards",
"turnovers": {"$sum": ["$IsInterception", "$IsFumble"]}
}
}
@jribnik
jribnik / sample.js
Last active Feb 4, 2016
$sample stage of simulation pipeline
View sample.js
sample = {"$sample":
{
"size": 60
}
}
@jribnik
jribnik / match.js
Last active Feb 4, 2016
$match stage of simulation pipeline
View match.js
match = {"$match":
{
"OffenseTeam": "DEN",
"$or": [{"PlayType": "PASS"}, {"PlayType": "RUSH"}],
"IsNoPlay": 0
}
}