"""Original arithmetic from declared public inputs or explicit worked assumptions."""
import csv
from pathlib import Path
results={'largest_control_share':2.2,'largest_treatment_share':5.6,'next_four_control_share':10-2.2,'next_four_treatment_share':14.5-5.6,'outside_five_control_share':100-10,'outside_five_treatment_share':100-14.5,'largest_gain_pp':5.6-2.2,'next_four_gain_pp':(14.5-5.6)-(10-2.2),'outside_five_change_pp':85.5-90,'largest_fraction_of_topfive_gain_pct':(5.6-2.2)/(14.5-10)*100,'worked_total_growth_threshold_pct':(10/9-1)*100,'worked_group_unit_change_at20growth_pct':(1.2*.09/.10-1)*100}
assert abs(results['largest_gain_pp']+results['next_four_gain_pp']+results['outside_five_change_pp'])<1e-8
p=Path(__file__).parent/"data";p.mkdir(exist_ok=True)
with (p/"concentration-decomposition.csv").open("w",newline="") as f:
 w=csv.writer(f);w.writerow(["metric","value"]);w.writerows(results.items())
print(results)
