+ add_3cell(row, '');
+ add_3cell(row, globals.points_played);
+ add_3cell(row, Math.floor(globals.playing_time_ms / 60000) + ' min');
+ add_3cell(row, Math.floor(globals.field_time_ms / 60000) + ' min');
+ add_3cell(row, globals.offensive_points_completed);
+ add_3cell(row, globals.defensive_points_completed);
+ rows.push(row);
+
+ return rows;
+}
+
+function make_table_per_point(players) {
+ let rows = [];
+ {
+ let header = document.createElement('tr');
+ add_cell(header, 'th', 'Player');
+ add_cell(header, 'th', 'Goals');
+ add_cell(header, 'th', 'Assists');
+ add_cell(header, 'th', 'Hockey assists');
+ add_cell(header, 'th', 'Ds');
+ add_cell(header, 'th', 'Throwaways');
+ add_cell(header, 'th', 'Drops');
+ add_cell(header, 'th', 'Touches');
+ rows.push(header);
+ }
+
+ let goals = 0;
+ let assists = 0;
+ let hockey_assists = 0;
+ let defenses = 0;
+ let throwaways = 0;
+ let drops = 0;
+ let touches = 0;
+ for (const [q,p] of Object.entries(players)) {
+ if (q === 'globals') continue;
+
+ // Can only happen once per point, so these are binomials.
+ let ci_goals = make_binomial_ci(p.goals, p.points_played, z);
+ let ci_assists = make_binomial_ci(p.assists, p.points_played, z);
+ let ci_hockey_assists = make_binomial_ci(p.hockey_assists, p.points_played, z);
+ // Arbitrarily desire at least 10% (not everybody can score or assist).
+ ci_goals.desired = 0.1;
+ ci_assists.desired = 0.1;
+ ci_hockey_assists.desired = 0.1;
+
+ let row = document.createElement('tr');
+ add_3cell(row, p.name, 'name'); // TODO: number?
+ add_3cell_ci(row, ci_goals);
+ add_3cell_ci(row, ci_assists);
+ add_3cell_ci(row, ci_hockey_assists);
+ add_3cell_ci(row, make_poisson_ci(p.defenses, p.points_played, z));
+ add_3cell_ci(row, make_poisson_ci(p.throwaways, p.points_played, z, true));
+ add_3cell_ci(row, make_poisson_ci(p.drops, p.points_played, z, true));
+ if (p.points_played > 0) {
+ add_3cell(row, p.touches == 0 ? 0 : (p.touches / p.points_played).toFixed(2));
+ } else {
+ add_3cell(row, 'N/A');
+ }
+ rows.push(row);
+
+ goals += p.goals;
+ assists += p.assists;
+ hockey_assists += p.hockey_assists;
+ defenses += p.defenses;
+ throwaways += p.throwaways;
+ drops += p.drops;
+ touches += p.touches;
+ }
+
+ // Globals.
+ let globals = players['globals'];
+ let row = document.createElement('tr');
+ add_3cell(row, '');
+ if (globals.points_played > 0) {
+ add_3cell(row, goals == 0 ? 0 : (goals / globals.points_played).toFixed(2));
+ add_3cell(row, assists == 0 ? 0 : (assists / globals.points_played).toFixed(2));
+ add_3cell(row, hockey_assists == 0 ? 0 : (hockey_assists / globals.points_played).toFixed(2));
+ add_3cell(row, defenses == 0 ? 0 : (defenses / globals.points_played).toFixed(2));
+ add_3cell(row, throwaways == 0 ? 0 : (throwaways / globals.points_played).toFixed(2));
+ add_3cell(row, drops == 0 ? 0 : (drops / globals.points_played).toFixed(2));
+ add_3cell(row, touches == 0 ? 0 : (touches / globals.points_played).toFixed(2));
+ } else {
+ add_3cell(row, 'N/A');
+ add_3cell(row, 'N/A');
+ add_3cell(row, 'N/A');
+ add_3cell(row, 'N/A');
+ add_3cell(row, 'N/A');
+ add_3cell(row, 'N/A');
+ add_3cell(row, 'N/A');
+ }