def check(theta, a0, a1, b0, b1): P = T.find_P(theta, a0, a1, b0, b1) Qs = St.satoshiTestComment(P) tlm = T.TLM(T.find_P(np.pi / 2, a0, a1, b0, b1)) wholeSp, thetaNew = St.SPlusCondition(P) Qw = newTest(theta, a0, a1, b0, b1) # flag = optimalTheta(a0,a1,b0,b1) Qn = T.is_exposed(theta, a0, a1, b0, b1, 0.0001) print(theta, a0, a1, b0, b1) print(Qs, Qw, Qn, "extremal") print(tlm, wholeSp)
def newTest(theta, a0, a1, b0, b1): Pmax = T.find_P(np.pi / 2, a0, a1, b0, b1) tlm = T.TLM(Pmax) if tlm: P = T.find_P(theta, a0, a1, b0, b1) wholeSp, thetaNew = St.SPlusCondition(P) if np.abs(thetaNew - theta) > acc: print("something is wrong with theta") if wholeSp: return 1 return 0
def testWagnerPoints(N): for theta in np.linspace(0, np.pi / 4, N): P = Pp.WagnerPoints(theta) b = Pp.getWagnerB(theta) _, a0, a1, b0, b1 = Pp.WagnerRealisation(theta) wholeSp, theta = St.SPlusCondition(P) stlm = St.STLM(P, theta) if wholeSp and stlm: Qs = 1 else: Qs = 0 accuracy = 0.001 Qn = T.is_exposed(theta, a0, a1, b0, b1, accuracy, limit=1) print(Qn, Qs)
def SpvsThreshold(N): for i in range(N): if i % 100 == 0: print(i) a0 = np.random.rand() * 2 * np.pi a1 = np.random.rand() * 2 * np.pi b0 = np.random.rand() * 2 * np.pi b1 = np.random.rand() * 2 * np.pi theta = np.random.rand() * np.pi / 2 thetaB = np.arcsin(T.hypoTreshold(a0, a1, b0, b1)) # print("graniczna", thetaB) P = T.find_P(theta, a0, a1, b0, b1) c1, thetan = St.SPlusCondition(P) if theta >= thetaB: c2 = 1 else: c2 = 0 if c1 != c2: print(c1, c2, "aaaaaa")
def tlmVSstlm(N): for i in range(N): if i % 100 == 0: print(f'{i+1}/{N}') a0 = np.random.rand() * 2 * np.pi a1 = np.random.rand() * 2 * np.pi b0 = np.random.rand() * 2 * np.pi b1 = np.random.rand() * 2 * np.pi theta = np.random.rand() * np.pi / 2 P1 = T.find_P(np.pi / 2, a0, a1, b0, b1) P2 = T.find_P(theta, a0, a1, b0, b1) tlm = T.TLM(P1) stlm = St.STLM(P2, theta) wholeSp, theta = St.SPlusCondition(P2) # print(tlm, stlm) if stlm and (not tlm): print(tlm, stlm) if stlm and (not tlm) and wholeSp: print(tlm, stlm, wholeSp) print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
def functionalBehaviour(N): for i in range(N): print(f'{i+1}/{N}') a0 = np.random.rand() * 2 * np.pi a1 = np.random.rand() * 2 * np.pi b0 = np.random.rand() * 2 * np.pi b1 = np.random.rand() * 2 * np.pi F1 = [] Tet = [] MAXI = [] tlm = T.TLM(T.find_P(np.pi / 2, a0, a1, b0, b1)) print(tlm) if tlm: thetag = T.getThetaFromSinSquared( T.hypoTreshold(a0, a1, b0, b1)**2) n = 500 Theta = np.linspace(thetag, np.pi / 2, n) for theta in Theta: # a0 = 3/4*np.pi # a1 = np.pi/4 # b0 = np.pi/2 # b1 = np.pi P = T.find_P(theta, a0, a1, b0, b1) wholeSp, thetaNew = St.SPlusCondition(P) # if wholeSp: # f1,m1 = T.Best_func(theta, a0, a1, b0, b1) f2, m2 = T.Best_func_restricted(theta, a0, a1, b0, b1) # print(m1-m2,"hmm") # print(f1) # print(f2) MAXI.append(m2) Tet.append(theta) F1.append(f2) # plt.plot(Tet,F1) plt.plot(Tet, MAXI) plt.show()
def nonnegativitySingularity(N): for i in range(1): a0 = 0 a1 = np.random.rand() * 2 * np.pi b0 = 0 b1 = np.random.rand() * 2 * np.pi P = T.find_P(np.pi / 2, a0, a1, b0, b1) # print(P) tlm = T.TLM(P) # Sp, Sm = St.SPlusTemp(P) # print(Sp) # print(Sm) # theta = np.random.rand()*np.pi/2 # thetaB = np.arcsin(T.hypoTreshold(a0,a1,b0,b1)) # print(thetaB) thetaGr = np.arcsin(T.hypoTresholdImproved(a0, a1, b0, b1)) print(thetaGr) Theta = np.linspace(0, np.pi / 2, N) for theta in Theta: # print(theta) # if i%100 == 0: # print(i) P = T.find_P(theta, a0, a1, b0, b1) stlm = St.STLM(P, theta) c1, thetan = St.SPlusCondition(P) if theta >= thetaGr: c2 = 1 else: c2 = 0 # sat = St.satoshiTest(P) # ex = T.is_exposed(theta,a0,a1,b0,b1, 0.001) if c1 and (not stlm): stlm2 = St.STLMComment(P, theta) print(tlm, stlm, c1, c2)