Skip to content

Instantly share code, notes, and snippets.

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:

@jribnik
jribnik / 2015simulation.js
Last active February 4, 2016 18:21
2015 simulation
{
"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,
@jribnik
jribnik / 2014simulation.js
Last active February 4, 2016 18:20
2014 simulation
{
"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,
@jribnik
jribnik / 2013simulation.js
Last active February 4, 2016 18:20
2013 simulation
{
"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 February 4, 2016 18:19
Aggregation stages for ensemble calculation
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 / match.js
Last active February 4, 2016 18:17
$match stage of simulation pipeline
match = {"$match":
{
"OffenseTeam": "DEN",
"$or": [{"PlayType": "PASS"}, {"PlayType": "RUSH"}],
"IsNoPlay": 0
}
}
for (var i = 0; i < 100000; i++) {
match = {"$match":
{
"OffenseTeam": "DEN",
"$or": [{"PlayType": "PASS"}, {"PlayType": "RUSH"}],
"IsNoPlay": 0
}
}
sample = {"$sample":
{
@jribnik
jribnik / sample.js
Last active February 4, 2016 17:29
$sample stage of simulation pipeline
sample = {"$sample":
{
"size": 60
}
}
@jribnik
jribnik / project.js
Last active February 4, 2016 17:29
$project stage of simulation pipeline
proj = {"$project":
{
"team": "$OffenseTeam",
"yards": "$Yards",
"turnovers": {"$sum": ["$IsInterception", "$IsFumble"]}
}
}
@jribnik
jribnik / group.js
Last active February 4, 2016 17:28
$group stage of simulation pipeline
group = {"$group":
{
"_id": "$team",
"yards": {"$sum": "$yards"},
"turnovers": {"$sum": "$turnovers"}
}
}