Lawfare Group → Knowledge Institute → Lawfare Academy

Reproduce the worked examples

Copy the complete code below into a UTF-8 file named verify.py and run python verify.py with Python 3. It uses only the standard library and performs exact or rational synthetic calculations. It does not access a network or learner records. Assertions fail if the expected synthetic results change.

These checks verify the stated arithmetic and query behavior, not independent academic acceptance or production migration safety.

from fractions import Fraction as F
import json
checks=[]
def ck(name,actual,expected):
 assert actual==expected,(name,actual,expected)
 checks.append(dict(case=name,actual=str(actual),expected=str(expected)))
ck('Illustrative funnel conditional useful customers',1000*F(1,10)*F(1,5)*F(9,10),F(18))
ck('Worked funnel qualified prospects',2000*F(1,10),F(200))
ck('Worked funnel bookings',200*F(1,4),F(50))
ck('Worked funnel completions',50*F(4,5),F(40))
ck('Worked funnel attributed net',40*160-5000,1400)
ck('Worked funnel baseline contribution',15*160,2400)
ck('Worked funnel incremental result',1400-2400,-1000)
ck('Full fulfillment changed net',50*160-5000,3000)
ck('Full fulfillment changed increment',3000-2400,600)
ck('Qualified group expected contribution per hour',F(1,4)*200,F(50))
ck('Weak group expected contribution per hour',F(1,10)*200,F(20))
ck('Sales offer A retained jobs',100-20-10,70)
ck('Sales offer B retained jobs',90-5-5,80)
ck('Sales offer A net',70*100-1000,6000)
ck('Sales offer B net',80*100-1200,6800)
ck('Sales offer A with extra booking commission',6000-100*10,5000)
ck('Sales offer B with extra booking commission',6800-90*10,5900)
ck('Separate cohort CAC',F(2400,20),F(120))
pv=80+F(3,5)*100/F(11,10)
ck('Separate cohort expected present contribution',pv,F(1480,11))
ck('Separate cohort net value',20*(pv-120),F(3200,11))
ck('Separate cohort immediate funding use',2400-20*80,800)
ck('Separate cohort lower retention total value',20*(80+F(2,5)*100/F(11,10)-120),F(-800,11))
ck('Small experiment observed rate uplift',F(30,200)-F(20,200),F(1,20))
ck('Small experiment observed increment',10*80-600,200)
ck('Large experiment observed rate uplift',F(60,500)-F(45,500),F(3,100))
ck('Large experiment observed increment',15*70-1200,-150)
ck('Large experiment attributed contribution not increment',60*70,4200)
ck('Small channel direct unit contribution',200-100-20,80)
ck('Small channel platform unit contribution',200-200*F(15,100)-100,F(70))
ck('Worked direct unit contribution',300-180-35,85)
ck('Worked platform unit contribution',300-180-300*F(1,5)-10,F(50))
ck('All displaced platform shift difference',100*(50-85),-3500)
ck('Forty displaced and sixty additional channel result',100*50-40*85,1600)
ck('Variant X retained',200-20,180)
ck('Variant Y retained',220-50,170)
ck('Variant X net',180*40-2000,5200)
ck('Variant Y net',170*40-2100,4700)
ck('Variant X including return processing',5200-20*15,4900)
ck('Variant Y including return processing',4700-50*15,3950)
ck('Full-window advantage',4900-3950,950)
ck('Cumulative CAC',F(900,6),F(150))
ck('Cumulative initial contribution',6*130,780)
ck('Cumulative initial net',780-900,-120)
later=6*F(1,2)*100/F(11,10)
ck('Cumulative expected later present contribution',later,F(3000,11))
ck('Cumulative original expected total net',later-120,F(1680,11))
ck('Original repeat probability threshold',F(120)*F(11,10)/600,F(11,50))
ck('Lower retention at twenty percent',-120+6*F(1,5)*100/F(11,10),F(-120,11))
ck('New transfer added onboarding cohort cost',6*20,120)
ck('New transfer initial net',780-900-120,-240)
ck('New transfer expected total at half repeat',-240+later,F(360,11))
ck('New transfer repeat threshold',F(240)*F(11,10)/600,F(11,25))
ck('New transfer value at forty percent repeat',-240+6*F(2,5)*100/F(11,10),F(-240,11))
print(json.dumps(dict(passed=True,scope='Synthetic digital marketing mechanisms only; not actual causal effects, platform terms, legal compliance or learner competence',checks=checks)))

Related chapters