-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathez_plot_curva3_large.py
More file actions
75 lines (52 loc) · 2.04 KB
/
ez_plot_curva3_large.py
File metadata and controls
75 lines (52 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt
import math
koef = 1000
firstlvl = 5000
rounds = 10
totallvl = 100
x = np.linspace(-2.0, 2.0, 1000)
sign = lambda c: 1 if c > 0 else -1 if c < 0 else 1
stepNeg = lambda c: 0 if c >= 0 else 1
# coeff = 0.6
# mathf = [ (1.0 / (1.0 + (1/coeff - 1)*x)) for coeff in [0.5, 0.6, 0.7, 0.8, 0.9 ] ]
# mathf = [ coeff + ((1.0-coeff)*0.2)*(x-1)/(1.0 + abs(x-1)) for coeff in [ 0.5, 0.6, 0.7, 0.8, 0.9 ] ]
# mathf = [ coeff + ((1.0-coeff)*0.2)*(x-1)/(1.0 + abs(x-1)) for coeff in [ 0.5, 0.6, 0.7, 0.8, 0.9 ] ]
# mathf = [ 1.0 + 0.75*2*(x-0.25)*1 / (1.0 + 2*abs(x-0.25)*1) ]
# mathf = [ np.exp(x) ]
# mathf = [ (5)*(1 - 1/(1 + (x+0.5) - (x+0.5)**2)) ]
# mathf = [ 4 - 5/(1.25 - c*(x+1)*x) for c in [0, 0.25, 0.5, 0.75, 1.0] ]
# mathf = [ 4 - 5/(1.25 - c*x*x) if c != 0 else -x*x for c in [0, 0.25, 0.5, 0.75, 1.0] ]
# mathf = [ 4 - 5/(1.25 - c*x*x) if c != 0 else -x*x for c in [0, 0.25, 0.5, 0.75, 1.0] ]
getC = lambda a,b: b/float(a) - b/(a+1.0)
# A = 5
# B = 2.0
mathf = [ -x*x,
# 5 - 10/(2.0 - 0.3333333*x*x),
# 2 - 10/(5.0 - 1.666666*x*x),
# 4 - 5/(1.25 - 0.25*(x+0)*x)
# np.sin(math.pi*2*x)/(math.pi*2*x) - 1.0
-x/(1 - x/(1+x))
]
mathf = [ 0.5 + 0.3*2*(x-c)*4 / (1.0 + 2*abs(x-c)*4) for c in [0.1, 0.4, 0.7] ]
# mathf = [ 1.0 - (1.0 / (1.0 + (1.0/(1.0 - c)-1.0)*x)) for c in [0.1, 0.99] ]
# mathf = [ 1.0/(1.0 + (1.0 - c)/c*(1 - x)) for c in [0.001, 0.99] ]
# mathf.extend([ (A - B/(B/A - getC(A,B)*x*x)) for A in [1,5,10000] ])
x = np.linspace(0.0, 1.0, 100)
def getZ(coeff):
z = np.zeros(100)
for l in range(len(z)):
z[l] = z[l-1]*coeff + (1.0 - coeff)*1.0 if l > 0 else 0
return z
mathf = [ getZ(c) for c in [0.1, 0.4, 0.7, 0.9] ]
# mathf.extend([ (A - B/(B/float(A) - getC(A,B)*x*x)) for A,B in [ [1,2], [4,5], [10,20]] ])
color = [ 'r.', 'g.', 'b.', 'y.', 'k.' ]
for i in range(len(mathf)):
plt.plot(x, mathf[i] , color[i])
plt.xlabel(r'$x$')
plt.ylabel(r'$f(x)$')
plt.grid(1)
# plt.ylim([-2.2, 2.2])
plt.ylim([0, 1.2])
plt.show()