from numpy import * import random def attenFrii(r): return ((lam/(4*pi))**2 * 1/(r**2)) c = 3e8 f=2.44e9 lam=c/f N = 10000 top=0 bottom=0 count=1 while(count <= 1000000): [Uab,Uac,Ubc] = [random.random()*40 for i in range(3)] [xa,xb,xc,ya,yb,yc] = [random.random()*1000 for i in range(6)] connAB=(attenFrii(sqrt((xa-xb)**2+(ya-yb)**2))>= 10**((-90+Uab)/10)) connAC=(attenFrii(sqrt((xa-xc)**2+(ya-yc)**2))>= 10**((-90+Uac)/10)) connBC=(attenFrii(sqrt((xb-xc)**2+(yb-yc)**2))>= 10**((-90+Ubc)/10)) if (connAB&connBC): top += 1 if connAC: bottom += 1 if count%100000==0 : print float(top)/float(bottom) count += 1