#!/usr/bin/env python3 """Standalone synthetic fixture; standard library only. No network, credentials or user paths.""" import json, math, statistics, sys, platform, datetime x=[100,110,120,130,140,150,160,170,180,2000] def nearest(a,p):return sorted(a)[max(0,math.ceil(len(a)*p)-1)] def linear(a,p): a=sorted(a);h=(len(a)-1)*p;i=math.floor(h);return a[i]+(h-i)*(a[min(i+1,len(a)-1)]-a[i]) y=x[:-1];a_group=[1]*100;b_group=[1000];pool=a_group+b_group a_p95=nearest(a_group,.95);b_p95=nearest(b_group,.95) result={"inputMs":x,"n":len(x),"mean":statistics.mean(x),"p50Nearest":nearest(x,.5),"p95Nearest":nearest(x,.95),"p95LinearR7":linear(x,.95),"withoutLast":{"n":len(y),"mean":statistics.mean(y),"p95Nearest":nearest(y,.95)},"averagingQuantiles":{"inputGroupsMs":{"a":a_group,"b":b_group},"aP95":a_p95,"bP95":b_p95,"naiveAverage":statistics.mean([a_p95,b_p95]),"pooledP95":nearest(pool,.95),"pooledN":101}} assert result['n']==10 and result['mean']==326 and result['p50Nearest']==140 assert result['p95Nearest']==2000 and math.isclose(result['p95LinearR7'],1181) assert result['withoutLast']=={'n':9,'mean':140,'p95Nearest':180} q=result['averagingQuantiles'] assert q['aP95']==1 and q['bP95']==1000 and q['naiveAverage']==500.5 assert q['pooledP95']==1 and q['pooledN']==101 print(json.dumps({"fixtureCreatedOn":"2026-10-15","executedAt":datetime.datetime.now(datetime.timezone.utc).isoformat(),"synthetic":True,"runtime":platform.python_version(),"result":result},ensure_ascii=False,indent=2))