def bayes_kill_max_frank(currentModel, newModel, kn, u, v, s, q, Q, zita, chain): current = np.sort(currentModel) new = np.sort(newModel) t1 = current[current != 0] min_old = np.min(t1) max_old = np.max(t1) L = len(u) l = len(new) ss = -1 R = 3/4 if np.any(new): t2 = new[new != 0] min_new = np.min(t2) max_new = np.max(t2) if min_old < min_new: if(s[1] == 2 and s[2] == 2): result1 = allfrank(u[:min_old], v[:min_old]) result2 = allfrank(u[min_old:min_new], v[min_old:min_new]) R = R * 1/3 else: if(s[1] == 2 and s[2] == 1): result1 = allfrank(u[:min_old], v[:min_old]) result2 = allclayton(u[min_old:min_new], v[min_old:min_new]) R = R * 2/3 else: if(s[1] == 1 and s[2] == 2): result1 = allclayton(u[:min_old], v[:min_old]) result2 = allfrank(u[min_old:min_new], v[min_old:min_new]) R = R * 2/3 else: if(s[1] == 2 and s[2] == 3): result1 = allfrank(u[:min_old], v[:min_old]) result2 = allgumbel(u[min_old:min_new], v[min_old:min_new]) R = R * 2/3 else: if(s[1] == 3 and s[2] == 2): result2 = allgumbel(u[:min_old], v[:min_old]) result1 = allfrank(u[min_old:min_new], v[min_old:min_new]) R = R * 2/3 resultOld = allfrank(u[:min_new], v[:min_new]) BFu = resultOld["BFu"] - result1["BFu"] - result2["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ((zita ** (chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current QQ = Q w = 13 else: new_model = current rejected = new QQ = q w = 14 else: if max_new < max_old and max_new != 0: if(s[1] == 2 and s[2] == 2): result1 = allfrank(u[max_new - 1:max_old], v[max_new - 1:max_old]) result2 = allfrank(u[max_old:L], v[max_old:L]) R = R * 1/3 else: if(s[1] == 1 and s[2] == 2): result2 = allclayton(u[max_new - 1:max_old], v[max_new - 1:max_old]) result1 = allfrank(u[max_old:L], v[max_old:L]) R = R * 2/3 else: if(s[1] == 2 and s[2] == 1): result2 = allfrank(u[max_new - 1:max_old], v[max_new - 1:max_old]) result1 = allclayton(u[max_old:L], v[max_old:L]) R = R * 2/3 else: if(s[1] == 2 and s[2] == 3): result2 = allfrank(u[max_new - 1:max_old], v[max_new - 1:max_old]) result1 = allgumbel(u[max_old:L], v[max_old:L]) R = R * 2/3 else: if(s[1] == 3 and s[2] == 2): result1 = allgumbel(u[max_new - 1:max_old], v[max_new - 1:max_old]) result2 = allfrank(u[max_old:L], v[max_old:L]) R = R * 2/3 resultOld = allfrank(u[max_new - 1:L], v[max_new - 1:L]) BFu = resultOld["BFu"] - result1["BFu"] - result2["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ((zita ** (chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current QQ = Q w = 15 else: new_model = current rejected = new QQ = q w = 16 else: place = kn if(s[1] == 2 and s[2] == 2): result1 = allfrank(u[current[place - 2] - 1:current[place - 1]], v[current[place - 2] - 1:current[place - 1]]) result2 = allfrank(u[current[place - 1]:current[place]], v[current[place - 1]:current[place]]) R = R * 1/3 else: if(s[1] == 2 and s[2] == 1): result1 = allfrank(u[current[place - 2] - 1:current[place - 1]], v[current[place - 2] - 1:current[place - 1]]) result2 = allclayton(u[current[place - 1]:current[place]], v[current[place - 1]:current[place]]) R = R * 2/3 else: if(s[1] == 1 and s[2] == 2): result1 = allclayton(u[current[place - 2] - 1:current[place - 1]], v[current[place - 2] - 1:current[place - 1]]) result2 = allfrank(u[current[place - 1]:current[place]], v[current[place - 1]:current[place]]) R = R * 2/3 else: if(s[1] == 2 and s[2] == 3): result1 = allfrank(u[current[place - 2] - 1:current[place - 1]], v[current[place - 2] - 1:current[place - 1]]) result2 = allgumbel(u[current[place - 1]:current[place]], v[current[place - 1]:current[place]]) R = R * 2/3 else: if(s[1] == 3 and s[2] == 2): result1 = allgumbel(u[current[place - 2] - 1:current[place - 1]], v[current[place - 2] - 1:current[place - 1]]) result2 = allfrank(u[current[place - 1]:current[place]], v[current[place - 1]:current[place]]) R = R * 2/3 resultOld = allfrank(u[current[place - 2] - 1:current[place]], v[current[place - 2] - 1:current[place]]) BFu = resultOld["BFu"] - result1["BFu"] - result2["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ((zita ** (chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current QQ = Q w = 17 else: new_model = current rejected = new QQ = q w = 18 else: if not np.any(new): R = 2 if(s[1] == 2 and s[2] == 2): result1 = allfrank(u[:max_old], v[:max_old]) result2 = allfrank(u[max_old:L], v[max_old:L]) R = R * 1/3 else: if(s[1] == 2 and s[2] == 1): result1 = allfrank(u[:max_old], v[:max_old]) result2 = allclayton(u[max_old:L], v[max_old:L]) R = R * 2/3 else: if(s[1] == 1 and s[2] == 2): result1 = allclayton(u[:max_old], v[:max_old]) result2 = allfrank(u[max_old:L], v[max_old:L]) R = R * 2/3 else: if(s[1] == 3 and s[2] == 2): result1 = allgumbel(u[:max_old], v[:max_old]) result2 = allfrank(u[max_old:L], v[max_old:L]) R = R * 2/3 else: if(s[1] == 2 and s[2] == 3): result2 = allfrank(u[:max_old], v[:max_old]) result1 = allgumbel(u[max_old:L], v[max_old:L]) R = R * 2/3 resultOld = allfrank(u, v) BFu = resultOld["BFu"] - result1["BFu"] - result2["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ((zita ** (chain - 1)) * BFu) + np.log(R))) and BFu.imag == 0: new_model = new rejected = current QQ = Q w = 19 else: new_model = current rejected = new QQ = q w = 20 result = {"new_model": new_model, "rejected": rejected, "w": w, "QQ": QQ, "ss": ss} return result
def bayes_change(currentModel, u, v, q, numbrk, zita, chain): current = np.sort(currentModel) l = len(currentModel) L = len(u) R = 1 / 3 ss = -1 q_new = 0 if np.count_nonzero(current) != 0: temp = current[current != 0] z = temp.shape[0] p = np.random.randint(low=1, high=z + 2) if p > 1 and p <= z: lower = temp[p - 2] upper = temp[p - 1] if q[p - 1] == 1: a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allclayton(u[lower - 1:upper], v[lower - 1:upper]) result2 = allfrank(u[lower - 1:upper], v[lower - 1:upper]) q_new = 2 else: result1 = allclayton(u[lower - 1:upper], v[lower - 1:upper]) result2 = allgumbel(u[lower - 1:upper], v[lower - 1:upper]) q_new = 3 else: if q[p - 1] == 2: a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allfrank(u[lower - 1:upper], v[lower - 1:upper]) result2 = allclayton(u[lower - 1:upper], v[lower - 1:upper]) q_new = 1 else: result1 = allfrank(u[lower - 1:upper], v[lower - 1:upper]) result2 = allgumbel(u[lower - 1:upper], v[lower - 1:upper]) q_new = 3 else: a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allgumbel(u[lower - 1:upper], v[lower - 1:upper]) result2 = allfrank(u[lower - 1:upper], v[lower - 1:upper]) q_new = 2 else: result1 = allgumbel(u[lower - 1:upper], v[lower - 1:upper]) result2 = allclayton(u[lower - 1:upper], v[lower - 1:upper]) q_new = 1 BFu = result2["BFu"] - result1["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = current q[p - 1] = q_new QQ = q rejected = current w = 37 else: new_model = current QQ = q rejected = current w = 38 else: if p > z and p != 1: if q[p - 1] == 1: a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allclayton(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) result2 = allfrank(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) q_new = 2 j = 0 else: result1 = allclayton(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) result2 = allgumbel(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) q_new = 3 j = 1 else: if q[p - 1] == 2: a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allfrank(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) result2 = allclayton(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) q_new = 1 j = 3 else: result1 = allfrank(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) result2 = allgumbel(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) q_new = 3 j = 4 else: a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allgumbel(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) result2 = allclayton(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) q_new = 1 j = 5 else: result1 = allgumbel(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) result2 = allfrank(u[np.max(temp) - 1:L], v[np.max(temp) - 1:L]) q_new = 2 j = 6 BFu = result2["BFu"] - result1["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = current q[p - 1] = q_new QQ = q j = 7 QQ[p - 1:numbrk + 1] = q_new * np.ones(numbrk + 1 - (p - 1), dtype=int) rejected = current w = 41 else: new_model = current QQ = q j = 8 rejected = current w = 42 else: if p == 1: if q[p - 1] == 1: a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allclayton(u[:np.min(temp)], v[:np.min(temp)]) result2 = allfrank(u[:np.min(temp)], v[:np.min(temp)]) q_new = 2 else: result1 = allclayton(u[:np.min(temp)], v[:np.min(temp)]) result2 = allgumbel(u[:np.min(temp)], v[:np.min(temp)]) q_new = 3 else: if q[p - 1] == 2: a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allfrank(u[:np.min(temp)], v[:np.min(temp)]) result2 = allclayton(u[:np.min(temp)], v[:np.min(temp)]) q_new = 1 else: result1 = allfrank(u[:np.min(temp)], v[:np.min(temp)]) result2 = allgumbel(u[:np.min(temp)], v[:np.min(temp)]) q_new = 3 else: a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allgumbel(u[:np.min(temp)], v[:np.min(temp)]) result2 = allclayton(u[:np.min(temp)], v[:np.min(temp)]) q_new = 1 else: result1 = allgumbel(u[:np.min(temp)], v[:np.min(temp)]) result2 = allfrank(u[:np.min(temp)], v[:np.min(temp)]) q_new = 2 BFu = result2["BFu"] - result1["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ((zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = current q[p - 1] = q_new QQ = q #QQ[p - 1:numbrk + 1] = q_new * np.ones(numbrk + 1 - (p - 1), dtype=int) rejected = current w = 61 else: new_model = current QQ = q rejected = current w = 62 else: if np.count_nonzero(current == 0) != 0: if (q == 2 * np.ones(numbrk + 1)).all(): a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allfrank(u[:L], v[:L]) result2 = allclayton(u[:L], v[:L]) q_new = 1 else: result1 = allfrank(u[:L], v[:L]) result2 = allgumbel(u[:L], v[:L]) q_new = 3 else: if (q == np.ones(numbrk + 1)).all(): a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allclayton(u[:L], v[:L]) result2 = allfrank(u[:L], v[:L]) q_new = 2 else: result1 = allclayton(u[:L], v[:L]) result2 = allgumbel(u[:L], v[:L]) q_new = 3 else: if (q == 3 * np.ones(numbrk + 1)).all(): a = np.random.uniform(low=np.nextafter(0.0, 1.0)) if a <= 1 / 2: result1 = allgumbel(u[:L], v[:L]) result2 = allfrank(u[:L], v[:L]) q_new = 2 else: result1 = allgumbel(u[:L], v[:L]) result2 = allclayton(u[:L], v[:L]) q_new = 1 BFu = result2["BFu"] - result1["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = current QQ = q_new * np.ones(numbrk + 1, dtype=int) rejected = current w = 49 else: new_model = current QQ = q rejected = current w = 50 result = { "new_model": new_model, "rejected": rejected, "w": w, "QQ": QQ, "ss": ss } return result
def bayes_birth_only_clay(currentModel, newModel, kn, u, v, s, q, Q, zita, chain): current = np.sort(currentModel) new = np.sort(newModel) t2 = new[new != 0] min_new = np.min(t2) max_new = np.max(t2) L = len(u) l = len(current) ss = -1 R = 1 / 2 if not np.any(current): if (s[1] == 1 and s[2] == 1): result1 = allclayton(u[:max_new], v[:max_new]) result2 = allclayton(u[max_new:L], v[max_new:L]) R = R * 3 else: if (s[1] == 1 and s[2] == 2): result1 = allclayton(u[:max_new], v[:max_new]) result2 = allfrank(u[max_new:L], v[max_new:L]) R = R * 3 / 2 else: if (s[1] == 2 and s[2] == 1): result1 = allfrank(u[:max_new], v[:max_new]) result2 = allclayton(u[max_new:L], v[max_new:L]) R = R * 3 / 2 else: if (s[1] == 1 and s[2] == 3): result1 = allclayton(u[:max_new], v[:max_new]) result2 = allgumbel(u[max_new:L], v[max_new:L]) R = R * 3 / 2 else: if (s[1] == 3 and s[2] == 1): result1 = allgumbel(u[:max_new], v[:max_new]) result2 = allclayton(u[max_new:L], v[max_new:L]) R = R * 3 / 2 resultOld = allclayton(u, v) BFu = result1["BFu"] + result2["BFu"] - resultOld["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current QQ = Q w = 35 else: new_model = current rejected = new QQ = q w = 36 result = { "new_model": new_model, "rejected": rejected, "w": w, "QQ": QQ, "ss": ss } else: result = bayes_birth_clay(currentModel, newModel, kn, u, v, s, q, Q, zita, chain) return result
def bayes_birth_clay(currentModel, newModel, kn, u, v, s, q, Q, zita, chain): current = np.sort(currentModel) new = np.sort(newModel) j2 = np.count_nonzero(new == 0, axis=0) t2 = new[new != 0] min_new = np.min(t2) max_new = np.max(t2) L = len(u) l = len(current) ss = -1 if j2 == 0: R = 4 / 3 else: R = 1 if np.any(current): t1 = current[current != 0] min_old = np.min(t1) max_old = np.max(t1) if min_new < min_old: if (s[1] == 1 and s[2] == 1): result1 = allclayton(u[:min_new], v[:min_new]) result2 = allclayton(u[min_new:min_old], v[min_new:min_old]) R = R * 3 else: if (s[1] == 1 and s[2] == 2): result1 = allclayton(u[:min_new], v[:min_new]) result2 = allfrank(u[min_new:min_old], v[min_new:min_old]) R = R * 3 / 2 else: if (s[1] == 2 and s[2] == 1): result1 = allfrank(u[:min_new], v[:min_new]) result2 = allclayton(u[min_new:min_old], v[min_new:min_old]) R = R * 3 / 2 else: if (s[1] == 1 and s[2] == 3): result1 = allclayton(u[:min_new], v[:min_new]) result2 = allgumbel(u[min_new:min_old], v[min_new:min_old]) R = R * 3 / 2 else: if (s[1] == 3 and s[2] == 1): result1 = allgumbel(u[:min_new], v[:min_new]) result2 = allclayton(u[min_new:min_old], v[min_new:min_old]) R = R * 3 / 2 resultOld = allclayton(u[:min_old], v[:min_old]) BFu = result1["BFu"] + result2["BFu"] - resultOld["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current QQ = Q w = 29 else: new_model = current rejected = new QQ = q w = 30 else: if max_new > max_old and max_old != 0: if (s[1] == 1 and s[2] == 1): result1 = allclayton(u[max_old - 1:max_new], v[max_old - 1:max_new]) result2 = allclayton(u[max_new:L], v[max_new:L]) R = R * 3 else: if (s[1] == 1 and s[2] == 2): result1 = allclayton(u[max_old - 1:max_new], v[max_old - 1:max_new]) result2 = allfrank(u[max_new:L], v[max_new:L]) R = R * 3 / 2 else: if (s[1] == 2 and s[2] == 1): result1 = allfrank(u[max_old - 1:max_new], v[max_old - 1:max_new]) result2 = allclayton(u[max_new:L], v[max_new:L]) R = R * 3 / 2 else: if (s[1] == 1 and s[2] == 3): result1 = allclayton(u[max_old - 1:max_new], v[max_old - 1:max_new]) result2 = allgumbel(u[max_new:L], v[max_new:L]) R = R * 3 / 2 else: if (s[1] == 3 and s[2] == 1): result1 = allgumbel( u[max_old:max_new], v[max_old:max_new]) result2 = allclayton( u[max_new:L], v[max_new:L]) R = R * 3 / 2 resultOld = allclayton(u[max_old - 1:L], v[max_old - 1:L]) BFu = result1["BFu"] + result2["BFu"] - resultOld["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current QQ = Q w = 31 else: new_model = current rejected = new QQ = q w = 32 else: place = np.where(new == kn)[0][0] + 1 if (s[1] == 1 and s[2] == 1): result1 = allclayton(u[new[place - 2] - 1:new[place - 1]], v[new[place - 2] - 1:new[place - 1]]) result2 = allclayton(u[new[place - 1]:new[place]], v[new[place - 1]:new[place]]) R = R * 3 else: if (s[1] == 1 and s[2] == 2): result1 = allclayton( u[new[place - 2] - 1:new[place - 1]], v[new[place - 2] - 1:new[place - 1]]) result2 = allfrank(u[new[place - 1]:new[place]], v[new[place - 1]:new[place]]) R = R * 3 / 2 else: if (s[1] == 2 and s[2] == 1): result1 = allfrank( u[new[place - 2] - 1:new[place - 1]], v[new[place - 2] - 1:new[place - 1]]) result2 = allclayton(u[new[place - 1]:new[place]], v[new[place - 1]:new[place]]) R = R * 3 / 2 else: if (s[1] == 1 and s[2] == 3): result1 = allclayton( u[new[place - 2] - 1:new[place - 1]], v[new[place - 2] - 1:new[place - 1]]) result2 = allgumbel( u[new[place - 1]:new[place]], v[new[place - 1]:new[place]]) R = R * 3 / 2 else: if (s[1] == 3 and s[2] == 1): result1 = allgumbel( u[new[place - 2] - 1:new[place - 1]], v[new[place - 2] - 1:new[place - 1]]) result2 = allclayton( u[new[place - 1]:new[place]], v[new[place - 1]:new[place]]) R = R * 3 / 2 resultOld = allclayton(u[new[place - 2] - 1:new[place]], v[new[place - 2] - 1:new[place]]) BFu = result1["BFu"] + result2["BFu"] - resultOld["BFu"] if BFu.imag: ss = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current QQ = Q w = 33 else: new_model = current rejected = new QQ = q w = 34 result = { "new_model": new_model, "rejected": rejected, "w": w, "QQ": QQ, "ss": ss } else: result = bayes_birth_only_clay(currentModel, newModel, kn, u, v, s, q, Q, zita, chain) return result
def bayes_move_clay(currentModel, newModel, kn, u, v, q, zita, chain): current = np.sort(currentModel) new = np.sort(newModel) t1 = current[current != 0] t2 = new[new != 0] min_old = np.min(t1) max_old = np.max(t1) min_new = np.min(t2) max_new = np.max(t2) L = len(u) l = len(current) s = -1 R = 1 if min_new < min_old and max_old != min_old: result1 = allclayton(u[:min_new], v[:min_new]) result2 = allclayton(u[min_new:t1[1]], v[min_new:t1[1]]) resultOld1 = allclayton(u[:min_old], v[:min_old]) resultOld2 = allclayton(u[min_old:t1[1]], v[min_old:t1[1]]) BFu = result1["BFu"] + result2["BFu"] - resultOld1["BFu"] - resultOld2[ "BFu"] if BFu.imag: s = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current w = 1 else: new_model = current rejected = new w = 2 else: if min_new > min_old and max_old != min_old: result1 = allclayton(u[:min_new], v[:min_new]) result2 = allclayton(u[min_new:t1[1]], v[min_new:t1[1]]) resultOld1 = allclayton(u[:min_old], v[:min_old]) resultOld2 = allclayton(u[min_old:t1[1]], v[min_old:t1[1]]) BFu = result1["BFu"] + result2["BFu"] - resultOld1[ "BFu"] - resultOld2["BFu"] if BFu.imag: s = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current w = 3 else: new_model = current rejected = new w = 4 elif (min_new < min_old or max_new > max_old) and max_old == min_old: result1 = allclayton(u[:t2[0]], v[:t2[0]]) result2 = allclayton(u[t2[0]:L], v[t2[0]:L]) resultOld1 = allclayton(u[:t1[0]], v[:t1[0]]) resultOld2 = allclayton(u[t1[0]:L], v[t1[0]:L]) BFu = result1["BFu"] + result2["BFu"] - resultOld1[ "BFu"] - resultOld2["BFu"] if BFu.imag: s = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current w = 5 else: new_model = current rejected = new w = 6 elif max_new > max_old and max_old != min_old: result1 = allclayton(u[t1[kn - 2] - 1:max_new], v[t1[kn - 2] - 1:max_new]) result2 = allclayton(u[max_new:L], v[max_new:L]) resultOld1 = allclayton(u[t1[kn - 2] - 1:t1[kn - 1]], v[t1[kn - 2] - 1:t1[kn - 1]]) resultOld2 = allclayton(u[t1[kn - 1]:L], v[t1[kn - 1]:L]) BFu = result1["BFu"] + result2["BFu"] - resultOld1[ "BFu"] - resultOld2["BFu"] if BFu.imag: s = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current w = 7 else: new_model = current rejected = new w = 8 elif max_new < max_old and max_old != min_old: result1 = allclayton(u[t1[kn - 2] - 1:max_new], v[t1[kn - 2] - 1:max_new]) result2 = allclayton(u[max_new:L], v[max_new:L]) resultOld1 = allclayton(u[t1[kn - 2] - 1:t1[kn - 1]], v[t1[kn - 2] - 1:t1[kn - 1]]) resultOld2 = allclayton(u[t1[kn - 1]:L], v[t1[kn - 1]:L]) BFu = result1["BFu"] + result2["BFu"] - resultOld1[ "BFu"] - resultOld2["BFu"] if BFu.imag: s = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current w = 9 else: new_model = current rejected = new w = 10 elif min_new == min_old and max_old == max_old: result1 = allclay(u[t2[kn - 2] - 1:t2[kn - 1]], v[t2[kn - 2] - 1:t2[kn - 1]]) result2 = allclay(u[t2[kn - 1] - 1:t2[kn]], v[t2[kn - 1] - 1:t2[kn]]) resultOld1 = allclay(u[t1[kn - 2] - 1:t1[kn - 1]], v[t1[kn - 2] - 1:t1[kn - 1]]) resultOld2 = allclay(u[t1[kn - 1] - 1:t1[kn]], v[t1[kn - 1] - 1:t1[kn]]) BFu = result1["BFu"] + result2["BFu"] - resultOld1[ "BFu"] - resultOld2["BFu"] if BFu.imag: s = -2 U2 = np.random.uniform(low=np.nextafter(0.0, 1.0)) if (np.log(U2) < min(0, ( (zita**(chain - 1)) * BFu) + np.log(R))) and not BFu.imag: new_model = new rejected = current w = 11 else: new_model = current rejected = new w = 12 QQ = q result = { "new_model": new_model, "rejected": rejected, "w": w, "QQ": QQ, "s": s } return result
new_model = new rejected = current QQ = Q w = 17 else: new_model = current rejected = new QQ = q w = 18 else: if not np.any(new): R = 2 if(s[1] == 1 and s[2] == 1): result1 = allclayton(u[:max_old], v[:max_old]) result2 = allclayton(u[max_old:L], v[max_old:L]) R = R * 1/3 else: if(s[1] == 1 and s[2] == 2): result1 = allclayton(u[:max_old], v[:max_old]) result2 = allfrank(u[max_old:L], v[max_old:L]) R = R * 2/3 else: if(s[1] == 2 and s[2] == 1): result1 = allfrank(u[:max_old], v[:max_old]) result2 = allclayton(u[max_old:L], v[max_old:L]) R = R * 2/3 else: if(s[1] == 1 and s[2] == 3): result1 = allclayton(u[:max_old], v[:max_old])