"""SNG variance simulation used on tourneymanager.net. 9-max SNG, payouts 50/30/20 of the prize pool, buy-in 10+1. A player's finish distribution is specified by P(1st), P(2nd), P(3rd); everything else is a bust. We draw N-game samples many times and look at the spread of the measured ROI. Pure Monte Carlo, no ICM.""" import random, statistics, json, sys random.seed(7) BUYIN, FEE = 10.0, 1.0 POOL = 9*BUYIN PAY = {1:0.50*POOL, 2:0.30*POOL, 3:0.20*POOL} def roi_true(p1,p2,p3): ev = p1*PAY[1]+p2*PAY[2]+p3*PAY[3] return (ev-(BUYIN+FEE))/(BUYIN+FEE) def sample(p1,p2,p3,n): r=random.random; tot=0.0 for _ in range(n): x=r() if x