Javascript port of stats simulation