"""Original arithmetic from declared public inputs or explicit worked assumptions."""
import csv
from pathlib import Path
import math
results={}
for name,b,se in [('adjusted',-.00529,.0177),('before_after',-.056,.00861)]:
 results[name+'_change_pct']=(math.exp(b)-1)*100;results[name+'_lower95_pct']=(math.exp(b-1.96*se)-1)*100;results[name+'_upper95_pct']=(math.exp(b+1.96*se)-1)*100
results['worked_cost_saved']=10000;results['worked_contribution_base']=500000;results['worked_loss_allowance_pct']=10000/500000*100
assert results['adjusted_lower95_pct']< -1 and results['adjusted_upper95_pct']>1
p=Path(__file__).parent/"data";p.mkdir(exist_ok=True)
with (p/"brand-search-decision.csv").open("w",newline="") as f:
 w=csv.writer(f);w.writerow(["metric","value"]);w.writerows(results.items())
print(results)
