Extract NBA empirical bell curves and quantiles
Beyond averages, NBA rotation minutes and blowout pull rules induce skewed tails. Enabling `include.distributions` returns empirical bell curves and P10/P50/P90 quantiles for game totals, spread margins, and every active player.
- What it is
- Runs the NBA simulator with `distributions: true` on game `6029936` to pull full game and player quantile profiles (mean, P10, P50, P90).
- When to use it
- Use this for prop-bet pricing, ceiling/floor tail modeling, and comparing median vs 90th-percentile DFS outcomes across starters and rotation players.
- What you get back
- Total points and spread margin quantile summaries plus the top 5 players ranked by mean DraftKings fantasy output with P50/P90 tails.
1.Run NBA SIM with empirical distributions enabled
Request both `summary` and `distributions` on free game `6029936` using seed `42`.
POST request (requires your API key in STAT_API_KEY). Run the SDK program on the right or the curl snippet below.
{
"game_id": 6029936,
"n_draws": 200,
"seed": 42,
"include": {
"summary": true,
"distributions": true,
"scorebox": false,
"pbp": false,
"scenarios": false,
"simulations": false
}
}const distRes = await api.sim.nba.run({ game_id: 6029936, n_draws: 200, seed: 42, include: { summary: true, distributions: true, scorebox: false, pbp: false, scenarios: false, simulations: false } })The complete program
Every step as one runnable file. It reads STAT_API_KEY from the environment, and is the same file that ships in the cookbook project for each SDK.
import { StatApi } from '@stat-api/client'
const api = new StatApi() // reads STAT_API_KEY from the environment
// Run NBA SIM with empirical distributions enabled
const distRes = await api.sim.nba.run({ game_id: 6029936, n_draws: 200, seed: 42, include: { summary: true, distributions: true, scorebox: false, pbp: false, scenarios: false, simulations: false } })
// Print game and player quantile distributions
const dist = distRes.output.distributions
const sumD = distRes.output.summary
if (!dist || !sumD) throw new Error('missing distributions or summary')
console.log(`Game ${sumD.game_id} | total mean=${dist.total_points.mean.toFixed(2)} p10=${dist.total_points.p10.toFixed(2)} p50=${dist.total_points.p50.toFixed(2)} p90=${dist.total_points.p90.toFixed(2)}`)
console.log(`SpreadHome mean=${dist.spread_margin_home.mean.toFixed(2)} p10=${dist.spread_margin_home.p10.toFixed(2)} p50=${dist.spread_margin_home.p50.toFixed(2)} p90=${dist.spread_margin_home.p90.toFixed(2)}`)
console.log(`Teams ${sumD.away_team.team_code}=${dist.away_points.mean.toFixed(2)} ${sumD.home_team.team_code}=${dist.home_points.mean.toFixed(2)}`)
const sortedCurves = [...dist.players].sort((a, b) => b.dk_pts.mean - a.dk_pts.mean || a.player_id - b.player_id)
for (const p of sortedCurves.slice(0, 5)) {
console.log(`Dist ${p.name} (${p.team_code}) | dk_p50=${p.dk_pts.p50.toFixed(2)} dk_p90=${p.dk_pts.p90.toFixed(2)} pts_p50=${p.points.p50.toFixed(2)}`)
}Verified output across all 4 SDKs
TypeScript, Python, Go, and Java execute cleanly and print byte-identical output:
Game 6029936 | total mean=220.41 p10=196.00 p50=219.00 p90=247.00
SpreadHome mean=-1.50 p10=-19.00 p50=-3.00 p90=16.10
Teams BOS=110.95 DET=109.46
Dist Jayson Tatum (BOS) | dk_p50=50.00 dk_p90=66.77 pts_p50=26.00
Dist Cade Cunningham (DET) | dk_p50=46.50 dk_p90=59.28 pts_p50=25.00
Dist Jalen Duren (DET) | dk_p50=34.00 dk_p90=46.05 pts_p50=16.00
Dist Payton Pritchard (BOS) | dk_p50=32.00 dk_p90=43.80 pts_p50=16.50
Dist Paul George (BOS) | dk_p50=30.88 dk_p90=43.78 pts_p50=16.00