|
|
@@ -39,6 +39,10 @@ def approx_target(c, stake, Sigma, k):
|
|
|
sigmas = [int((c/Sigma)**i * (L/fact(i))) for i in range(1, k+1)]
|
|
|
return -1*approx_target_in_zk(sigmas, stake)
|
|
|
|
|
|
+def approx_target_no_div(c, stake, Sigma, k):
|
|
|
+ sigmas = [(c/Sigma)**i * (L/fact(i)) for i in range(1, k+1)]
|
|
|
+ return -1*approx_target_in_zk(sigmas, stake)
|
|
|
+
|
|
|
|
|
|
f = 0.5
|
|
|
x = (1-f)
|
|
|
@@ -54,6 +58,7 @@ T_approx_2term = []
|
|
|
T_approx_3term = []
|
|
|
T_approx_5term = []
|
|
|
k=7
|
|
|
+START=1
|
|
|
|
|
|
for i in range(TOTAL):
|
|
|
if random.random() >= 0.9:
|
|
|
@@ -62,6 +67,9 @@ for i in range(TOTAL):
|
|
|
col = []
|
|
|
t = target(f, stake/(i+1.0))
|
|
|
col += [t]
|
|
|
+ for j in range(1,k+1):
|
|
|
+ t_approx = approx_target_no_div(c, stake, (i+1.0), j)
|
|
|
+ col += [t_approx]
|
|
|
for j in range(1,k+1):
|
|
|
t_approx = approx_target(c, stake, (i+1.0), j)
|
|
|
col += [t_approx]
|
|
|
@@ -69,26 +77,45 @@ for i in range(TOTAL):
|
|
|
|
|
|
targets = np.array(targets).T
|
|
|
|
|
|
-plt.subplot(2,1,1)
|
|
|
+plt.subplot(4,1,1)
|
|
|
|
|
|
plt.plot(targets[0])
|
|
|
-
|
|
|
-START=1
|
|
|
-
|
|
|
for i in range(START,k+1):
|
|
|
plt.plot(targets[i])
|
|
|
|
|
|
plt.legend(["target"] + ["{} terms".format(i) for i in range(START,k+1)], loc='upper right')
|
|
|
|
|
|
-Deltas = [0]
|
|
|
-for j in range(START,k+1):
|
|
|
+Deltas = []
|
|
|
+for j in range(START+1,k+1):
|
|
|
diff = np.array(targets[j])-np.array(targets[j-1])
|
|
|
delta = np.sum(diff)
|
|
|
Deltas += [delta]
|
|
|
|
|
|
-plt.subplot(2,1,2)
|
|
|
+print(len(Deltas))
|
|
|
+plt.subplot(4,1,2)
|
|
|
Deltas_derivates = np.poly1d(Deltas)
|
|
|
plt.plot(Deltas)
|
|
|
plt.plot(Deltas_derivates.deriv())
|
|
|
plt.legend(["delta", "derivative"], loc='upper right')
|
|
|
+
|
|
|
+plt.subplot(4,1,3)
|
|
|
+plt.plot(targets[0])
|
|
|
+for i in range(k,2*(k)+1):
|
|
|
+ plt.plot(targets[i])
|
|
|
+
|
|
|
+plt.legend(["target"] + ["{} terms(with div)".format(i) for i in range(START,k+1)] , loc='upper right')
|
|
|
+
|
|
|
+Deltas = []
|
|
|
+for j in range(k+2,2*(k)+1):
|
|
|
+ diff = np.array(targets[j])-np.array(targets[j-1])
|
|
|
+ delta = np.sum(diff)
|
|
|
+ Deltas += [delta]
|
|
|
+
|
|
|
+plt.subplot(4,1,4)
|
|
|
+Deltas_derivates = np.poly1d(Deltas)
|
|
|
+plt.plot(Deltas)
|
|
|
+plt.plot(Deltas_derivates.deriv())
|
|
|
+plt.legend(["delta(with div)", "derivative(with div)"], loc='upper right')
|
|
|
+
|
|
|
+
|
|
|
plt.savefig("target.png")
|