Step 3 computes the Shapley value for each player.
The Shapley number for each project(player) is computed as an average of the sum of incremental contributions of each project (in this example, three total), using the combined SQL query shown below. The results match with those described above.
SQL Calls
Compute Shapley value for each player:
SELECT player, SUM(partial_avg) / 3 AS shapley_value FROM ( SELECT player, size, SUM(partial_value) AS partial_avg FROM ( SELECT player, (project_comb_cost."value" - project_addone_cost."value") / divisor AS partial_value, project_addone_cost.size AS size FROM project_comb_cost INNER JOIN project_addone_cost ON (project_comb_cost.comb = project_addone_cost.comb2) ) AS stratum GROUP BY player, size ) AS stratum_avg GROUP BY player ORDER BY player;
Output
player | shapley_value |
---|---|
1 | 2000 |
2 | 10000 |
3 | 8000 |